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.
Which of the following correctly demonstrates pointer arithmetic?
Answer: A
Option A shows pointer arithmetic where p++ increments the pointer by the size of int (4 bytes). Other options are regular arithmetic operations.
Q.22Hard
What is the output of the following code? int a = 5; int *p = &a; int **q = &p; printf("%d", **q);
Answer: A
q is a pointer to pointer p. **q dereferences both pointers, giving the value of a, which is 5.
Q.23Hard
What is true about the variable declared as 'extern int count;' inside a function?
Answer: B
extern is a declaration (not definition) that tells compiler the variable exists elsewhere in program. It provides global scope.
Q.24Hard
Consider a structure with int (4 bytes), char (1 byte), and double (8 bytes). What is the minimum size due to alignment requirements?
Answer: C
Due to structure padding/alignment, the size becomes 24 bytes (8-byte alignment for double). Members are padded to maintain alignment.
Q.25Hard
Which of the following statements about type qualifiers is INCORRECT?
Answer: C
restrict prevents pointer aliasing (not allows). It tells compiler that pointer is the only way to access that object.
Q.26Hard
In the declaration 'volatile int x;', what does volatile signify?
Answer: A
volatile tells the compiler that the variable's value may change unexpectedly (e.g., by hardware, signals, or another thread), so the compiler should not optimize it.
Q.27Hard
In the declaration 'int *p, q;', what are the data types?
Answer: B
The '*' applies only to the immediately following variable. So 'int *p' declares p as pointer to int, and 'q' is just an int.
Q.28Hard
What is the purpose of the 'restrict' keyword in modern C?
Answer: B
restrict (C99) informs the compiler that a pointer is the sole accessor to the object, enabling optimization. It doesn't prevent modification.
Q.29Hard
What is the difference between 'const int *p' and 'int * const p'?
Answer: C
'const int *p' - pointer can change but value cannot. 'int * const p' - value can change but pointer cannot.
Q.30Hard
What is printed by: int x = 5; printf("%d %d", x++, ++x);?
Answer: C
Modifying variable x twice without intervening sequence point causes undefined behavior.
Q.31Hard
Which of the following correctly declares a constant pointer to a constant integer?
Answer: D
Both 'const int * const p' and 'int const * const p' are equivalent and declare constant pointer to constant integer.
Q.32Hard
Which of the following statements about 'register' keyword is TRUE?
Answer: D
Register is a hint only; compiler may ignore it. You cannot use & operator on register variables.
Q.33Hard
What is the primary purpose of the 'restrict' keyword introduced in C99?
Answer: B
The 'restrict' qualifier tells the compiler that a pointer is the only way to access that object, enabling optimizations.
Q.34Hard
What happens in this code: int arr[5]; int *p = &arr[0]; printf("%d", sizeof(p));
Answer: B
p is a pointer variable, so sizeof(p) returns the size of the pointer itself (4 bytes on 32-bit, 8 bytes on 64-bit systems), not the array.
Q.35Hard
What will be the result of the following expression: float x = 0.1 + 0.2; if(x == 0.3) printf("Equal"); else printf("Not Equal");
Answer: B
Due to floating-point precision limitations, 0.1 + 0.2 does not exactly equal 0.3 in binary representation. Direct comparison with == fails.
Q.36Hard
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.37Hard
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.38Hard
What is the output of this complex nested control flow? int x = 1, y = 2; if (x < y) { x++; y--; if (x == y) printf("Equal"); else printf("NotEqual"); }
Answer: A
x=1, y=2. Since 1 < 2, x becomes 2 and y becomes 1. Now x != y, but after operations x=2, y=1. Wait: x++ makes x=2, y-- makes y=1. So x==y is false, printing 'NotEqual'. Rechecking: 1 < 2 is true, so enter if. x becomes 2, y becomes 1. 2 == 1 is false, so else executes, printing 'NotEqual'.
Q.39Hard
What happens when continue is used in a for loop with a post-increment expression?
Answer: B
When continue is executed in a for loop, the post-increment (i++) still executes before the condition is checked again. Only the body statements after continue are skipped.
Q.40Hard
What is the effect of using multiple break statements in nested loops?
Answer: C
Each break statement exits only its immediately enclosing loop. To exit multiple nested loops, you need one break for each level you want to exit.