C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.
Consider a scenario where you need to store a variable that can hold values up to 10 billion. Which data type is most suitable?
Answer: C
int max is ~2.1 billion, long int varies (may be 32 or 64 bits). long long int guarantees 64 bits with max ~9.2 quintillion, sufficient for 10 billion.
Q.182Hard
What happens when a volatile variable is declared in a multi-threaded C program?
Answer: B
volatile tells compiler not to optimize variable accesses and to fetch fresh value from memory, useful for hardware registers and shared memory, but doesn't guarantee thread-safety without synchronization.
Q.183Easy
In C programming, when you declare a variable as 'const int x = 5;', what happens if you try to modify it within the program?
Answer: B
The 'const' keyword creates a read-only variable. Once initialized, attempting to modify a const variable results in a compilation error (error: assignment of read-only variable). This is enforced at compile-time, not runtime.
Q.184Easy
What will be the output of the following C code? int x = 5; if (x > 3) printf("A"); else printf("B");
Answer: A
Since x = 5 and 5 > 3 is true, the if block executes and prints 'A'.
Q.185Easy
Which of the following is NOT a valid control flow statement in C?
Answer: B
foreach is not a standard C control flow statement. C has if-else, switch, for, while, do-while, and goto.
Q.186Easy
What is the output of this code? for (int i = 0; i < 3; i++) printf("%d ", i);
Answer: A
The loop runs from i=0 to i=2 (i < 3), printing '0 1 2 '.
Q.187Easy
What is the difference between 'break' and 'continue' in loops?
Answer: A
break terminates the loop entirely, while continue jumps to the next iteration without executing remaining statements.
Q.188Medium
What will be printed? int x = 0; if (x = 5) printf("True"); else printf("False");
Answer: A
x = 5 assigns 5 to x and evaluates to 5 (non-zero), which is true. So 'True' is printed.
Q.189Medium
What is the output? for (int i = 1; i <= 5; i++) { if (i == 3) break; printf("%d ", i); }
Answer: A
When i becomes 3, break is executed, exiting the loop. So only 1 and 2 are printed.
Q.190Medium
What does the following nested if-else produce? int a = 10, b = 20; if (a > b) if (b > 0) printf("X"); else printf("Y");
Answer: B
The else clause pairs with the inner if. Since a > b is false, the else block executes printing 'Y'.
Q.191Medium
What is the output of this switch statement? int x = 2; switch(x) { case 1: printf("One"); break; case 2: printf("Two"); case 3: printf("Three"); break; default: printf("Other"); }
Answer: B
Case 2 matches. Since there's no break after case 2, fall-through occurs to case 3, printing 'TwoThree'.
Q.192Medium
How many times will this loop execute? for (int i = 0; i < 5; ++i) { if (i == 2) continue; if (i == 4) break; }
Answer: C
Loop runs for i=0,1,2,3. When i=4, break is executed. The body executes 4 times (iterations for i=0,1,2,3).
Q.193Medium
What is printed by this code? int x = 5; while (x-- > 0) printf("%d ", x);
Answer: B
x-- returns 5 first, then decrements to 4. Loop runs while x > 0, printing 4, 3, 2, 1, 0.
Q.194Medium
What is the output? int n = 1; do { printf("%d ", n); n++; } while (n > 5);
Answer: A
The do-while executes once (prints 1), then n becomes 2. Since 2 > 5 is false, the loop exits.
Q.195Easy
Analyze the ternary operator: int x = (5 > 3) ? 10 : 20; What is the value of x?
Answer: A
Since 5 > 3 is true, the ternary operator returns 10, so x = 10.
Q.196Hard
What is the output of this program? for (int i = 1; i <= 3; i++) for (int j = 1; j <= 2; j++) printf("%d", i*j); printf("\n");
Answer: A
Nested loops: outer i=1,2,3; inner j=1,2. Prints products: 1*1=1, 1*2=2 (newline), 2*1=2, 2*2=4 (newline), etc.
Q.197Easy
What is the behavior of goto in C?
Answer: A
goto transfers program control to a labeled location, though it's discouraged for code readability.
Q.198Medium
Determine the output: int i = 0; while (i < 3) { printf("%d ", i++); }
Answer: A
i starts at 0. Loop prints i then increments: prints 0, then 1, then 2. When i becomes 3, condition fails.
Q.199Medium
What does this code segment output? for (int i = 0; i < 5; i++) { if (i % 2 == 0) continue; printf("%d ", i); }
Answer: A
continue skips even numbers. Loop prints only odd values: 1 and 3.
Q.200Easy
Which statement is used to skip remaining iterations and move to next iteration?
Answer: B
continue is the C keyword that jumps to the next iteration of the loop.