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.
Dangling pointer occurs when memory is freed but pointer still references that location. This causes undefined behavior.
Q.562Medium
For function: void modify(int *x) { *x = 20; } If called as modify(&a), what changes?
Answer: B
Passing address allows function to modify original variable. *x = 20 changes the value at that address.
Q.563Easy
What is the result of: int x = 5; int *p = &x; int *q = p; if p == q?
Answer: B
Both p and q point to same address of x, so p == q evaluates to true (1).
Q.564Hard
In pointer to function: int (*ptr)(int, int); What does this declare?
Answer: B
Parentheses around *ptr give pointer priority. It's a pointer to a function taking 2 ints and returning int.
Q.565Easy
What happens with: int arr[10]; int *p = arr; *p = 5; printf("%d", arr[0]);?
Answer: B
p points to arr[0]. *p = 5 modifies arr[0]. Printing arr[0] displays 5.
Q.566Medium
Which of the following is valid pointer comparison?
Answer: C
Pointers of same type can be compared using <, >, ==, !=. Comparing with integers or different types is invalid.
Q.567Medium
In: int *p; *p = 10; What is the issue?
Answer: B
p is not initialized to valid address. Dereferencing causes undefined behavior (writing to random memory location).
Q.568Hard
What is the output of: printf("%p", NULL);?
Answer: C
%p prints pointer values. NULL representation depends on implementation, commonly shown as 0x0 or (nil).
Q.569Hard
For dynamic 2D array: int arr = (int)malloc(n * sizeof(int*)); What's missing?
Answer: B
This allocates row pointers only. Each row needs allocation: arr[i] = (int*)malloc(m * sizeof(int));
Q.570Hard
What is the relationship between arrays and pointers?
Answer: C
Array name acts as pointer to first element in expressions but they're distinct. &arr and arr differ in type.
Q.571Hard
Consider: const int *p; and int * const q; Which statement is true?
Answer: C
const int *p: pointer can change, data cannot. int * const q: pointer cannot change, data can be modified.
Q.572Easy
What is the output of the following code? int x = 10; int *p = &x; int **q = &p; printf("%d", **q);
Answer: A
q is a pointer to pointer p. **q dereferences q twice: first to get p, then to get the value of x which is 10.
Q.573Easy
Consider the declaration: const int *p; and int * const q; Which statement is TRUE?
Answer: B
const int *p means p can change but the data it points to cannot. int * const q means q cannot change but the data it points to can be modified.
Q.574Medium
For dynamic 2D array allocation using int arr = (int)malloc(n*sizeof(int*)); what must be done next?
Answer: B
After allocating memory for pointers, each pointer (row) must be allocated memory individually in a loop before accessing arr[i][j].
Q.575Easy
What is the primary issue with this code? int *p; *p = 10;
Answer: B
p is declared but not initialized to point to any valid memory location. Dereferencing an uninitialized pointer causes undefined behavior.
Q.576Medium
Which of the following is a valid pointer comparison in C?
Answer: B
Comparing pointers with NULL is valid. Comparing unrelated pointers or subtracting pointers from different arrays is undefined behavior.
Q.577Medium
What will be the output? int arr[5] = {1,2,3,4,5}; int *p = arr; p += 2; printf("%d", *p);
Answer: C
p points to arr[0]. After p += 2, p points to arr[2] which contains value 3. Pointer arithmetic moves by element size.
Q.578Medium
In pointer to function declaration: int (*ptr)(int, int); which statement is correct?
Answer: B
The parentheses around *ptr indicate ptr is a pointer. It points to a function that takes two int parameters and returns an int.
Q.579Medium
Consider a function void modify(int *x) { *x = 20; } called as modify(&y). What happens?
Answer: B
When &y is passed to a function expecting a pointer parameter, the address is passed. Changes via pointer dereference affect the original variable.
Q.580Easy
What is the primary difference between a structure and a union in C?
Answer: A
In structures, each member gets its own memory space. In unions, all members share the same memory location, so only one member can hold a value at a time.