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.
volatile tells the compiler that a variable's value can change unexpectedly (e.g., in hardware registers or interrupt handlers), so it should not optimize away repeated reads.
Q.37Medium
Which of the following about register variables is TRUE?
Answer: B
register keyword suggests the compiler to store the variable in CPU register for faster access. Modern compilers often ignore this hint. You cannot take address of register variables.
Q.38Medium
Consider the following code: int x = 5; int *ptr = &x; int **pptr = &ptr; printf("%d", **pptr); What is the output?
Answer: A
pptr is a pointer to pointer. **pptr dereferences twice: first to get ptr, then to get x's value which is 5.
Q.39Medium
What will be printed by the following code? #include<stdio.h> int main() { int arr[5] = {1, 2, 3, 4, 5}; int *p = arr; printf("%d %d", *(p+2), arr[2]); return 0; }
Answer: A
*(p+2) accesses the element at index 2 (value 3), and arr[2] also accesses index 2 (value 3). Both print 3.
Q.40Medium
What is the output of this code? #include<stdio.h> int main() { int a = 5, b = 10; a = a ^ b; b = a ^ b; a = a ^ b; printf("%d %d", a, b); return 0; }
Answer: B
This is a classic XOR swap algorithm. After three XOR operations, a and b exchange their values. Result: a=10, b=5.