Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Control Instructions Questions
Analyze a for-loop with a post-printf expression and boolean control variable: what prints? #include
int main() { int x=1, y=1; for(; y; printf("%d %d ", x, y)) { y = x++ <= 5; } printf(" "); return 0; }
Empty for-loop control fields in C: is for(;;) valid and what does this program do? #include
int main() { int i=1; for(;;) { printf("%d ", i++); if(i>10) break; } return 0; }
C language – switch-case validation and constants: Point out the specific compile-time error(s) in this program. #include
int main() { int P = 10; switch (P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; }
C language – while loop syntax sanity check: Point out the compile-time error (if any) in this loop with a missing condition. #include
int main() { int i = 1; while() { printf("%d ", i++); if (i > 10) break; } return 0; }
C language – switch body semantics and fall-through behavior: Identify whether this program has a compilation error and what it prints. #include
int main() { int i = 1; switch (i) { printf("This is c program."); case 1: printf("Case1"); break; case 2: printf("Case2"); break; } return 0; }
C control flow and goto scope rules: Point out the error in this program that jumps to a label inside another function. #include
int main() { void fun(); int i = 1; while (i <= 5) { printf("%d ", i); if (i > 2) goto here; i++; } return 0; } void fun() { here: printf("It works"); }
C switch-case constants and duplicates: Which compilation error(s) will be reported for this switch that includes a computed case and a literal with the same value? #include
int main() { int a = 5; switch (a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }
C conditional operator (?:) usage with assignments: Determine the program output and understand why the ternary expression is valid. #include
int main() { int a = 10, b; a >= 5 ? b = 100 : b = 200; printf("%d ", b); return 0; }
C switch with computed case labels: Identify whether this program is valid and if any error exists when case uses an arithmetic expression. #include
int main() { int i = 1; switch (i) { case 1: printf("Case1"); break; case 12+4: printf("Case2"); break; } return 0; }
C switch with empty body: Does the following program contain any error when a switch has no case/default blocks? #include
int main() { int a = 10; switch (a) { } printf("This is c program."); return 0; }
C if–else chain and statement termination: Identify the compilation error in this program with a missing semicolon. #include
int main() { int x = 30, y = 40; if (x == y) printf("x is equal to y "); else if (x > y) printf("x is greater than y "); else if (x < y) printf("x is less than y ") return 0; }
C conditional operator with assignments – behavior and output: Is there any error in this program, and what will it print? #include
int main() { int n = 0, y = 1; y == 1 ? n = 0 : n = 1; if (n) printf("Yes "); else printf("No "); return 0; }
In C programming, consider the following code (normalize line breaks exactly as shown): #include
int main() { int i = 10, j = 15; if(i % 2 = j % 3) printf("CuriousTab "); return 0; } Which compiler diagnosis best applies to this program and why?
In C, analyze the following program and determine the correct behavior (note the real line breaks): #include
#include
int main() { int i = 0; i++; if(i <= 5) { printf("CuriousTab "); exit(0); main(); } return 0; } Which statement best describes what actually happens when it runs?
Consider this C program (preserve the exact newlines): #include
int main() { int x = 10, y = 100%90, i; for(i = 1; i < 10; i++) if(x != y); printf("x = %d y = %d ", x, y); return 0; } Which statements about its output and syntax are correct?
Analyze the following C program (with real newlines) and select the best diagnosis: #include
int main() { int i = 10, j = 20; if(i = 5) && if(j = 10) printf("Have a nice day"); return 0; } What is the correct compiler outcome?
C language theory: Which of the following statements about for, while, and do-while is/are correct? 1) A for loop always runs faster than a while loop. 2) Anything achievable with a for loop can also be written using a while loop. 3) The construct for(;;); creates an infinite loop. 4) A for loop guarantees at least one execution of the loop body.
C if-else semantics: Which of the following are correct? 1) Every if-else statement can be replaced by an equivalent expression using the ?: (conditional) operator. 2) Nested if-else statements are allowed. 3) Multiple statements are permitted inside an if block. 4) Multiple statements are permitted inside an else block.
C switch semantics: which statements are correct? 1) switch is useful for testing a variable against a set of specific discrete values. 2) switch is ideal for checking whether a value falls into arbitrary numeric ranges. 3) Compilers often implement a jump table for switch cases (where appropriate). 4) A break is not mandatory after every case label.
1
2
3