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.
What will be the output? int arr[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}}; int *p = (int *)arr; printf("%d", *(p+5));
Answer: B
Converting 2D array to int pointer treats it as 1D. p+5 points to the 6th element (0-indexed), which is 6.
Q.102Hard
What does realloc() do?
Answer: B
realloc() changes the size of previously allocated memory. It may return the same address or a new one depending on availability.
Q.103Hard
What is the primary use of const pointer (int * const p)?
Answer: B
int * const p is a constant pointer - the pointer address cannot be changed, but the value it points to can be modified.
Q.104Hard
Consider: int arr[] = {1,2,3,4,5}; int *p = arr + 2; What is arr - p?
Answer: A
arr points to arr[0], p points to arr[2]. arr - p = -2 (p is 2 positions ahead).
Q.105Hard
What is malloc(0) likely to return?
Answer: B
malloc(0) behavior is implementation-defined but typically returns a valid pointer. Freeing it is safe.
Q.106Hard
What will be printed? int *p = (int*)malloc(5 * sizeof(int)); int *q = p; p = NULL; free(q);
Answer: C
q still holds the address even though p is NULL. free(q) properly deallocates memory.
Q.107Hard
What is the difference between arr and &arr if arr is an array? int arr[5];
Answer: B
arr decays to pointer to first element (int*). &arr is pointer to whole array (int(*)[5]). Pointer arithmetic differs.
Q.108Hard
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.109Hard
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.110Hard
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.111Hard
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.112Hard
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.113Hard
Which statement is true about nested structures in C?
Answer: B
C allows structures to have other structures as members. This is called nested structures and is a common practice.
Q.114Hard
What happens if you assign a union member and then access another member? struct u { int a; char b; }; u.a = 257; printf("%d", u.b);
Answer: B
In a union, both members share memory. 257 in binary is 100000001. u.b (char) reads only the LSB, which is 1.
Q.115Hard
How can you initialize a structure array of 10 elements partially in C?
Answer: D
Both {0} and {} will initialize all members to zero. These are equivalent in C99 and later standards.
Q.116Hard
What is the difference between self-referential and recursive structures?
Answer: B
Self-referential structures contain pointers to the same structure type (like linked list nodes). Recursion refers to function calls, not structures.
Q.117Hard
Given union test { int x; char y[4]; }; If you set y[0]=65, y[1]=66, what happens to x?
Answer: C
Since union members share memory, setting y[0]=65 and y[1]=66 overwrites the int x value. The exact value depends on endianness.
Q.118Hard
Which approach is more memory efficient for storing 100 flags: array of char or bit fields in a structure?
Answer: B
Bit fields can pack 8 flags per byte, so 100 flags need ~13 bytes. Char array needs 100 bytes. Bit fields are more memory-efficient for flag storage.
Q.119Hard
In nested structures with pointers, which access method is correct? struct outer { struct inner *ptr; } *o; Accessing inner's member x:
Answer: D
Both o->ptr->x and (*o).ptr->x are equivalent. Arrow operator can chain for pointers, and (*pointer).member is equivalent to pointer->member.
Q.120Hard
What is the relationship between structure alignment and padding in modern C compilers?
Answer: B
Compilers add padding bytes between structure members to align them on boundaries (usually power of 2), improving memory access performance on the target architecture.