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 is the size of a pointer variable on a 32-bit system?
Answer: B
On a 32-bit system, all pointers are 4 bytes (32 bits) regardless of the data type they point to.
Q.502Easy
Consider: int x = 10; int *p = &x; What does the expression *p represent?
Answer: C
The dereference operator (*) accesses the value at the address pointed to by p, which is the value 10.
Q.503Easy
Which operator is used to get the address of a variable?
Answer: B
The & (address-of) operator returns the memory address of a variable.
Q.504Easy
What will be printed by the code: char *ptr = "Hello"; printf("%c", *ptr);
Answer: A
ptr points to the first character of the string, so *ptr dereferences to 'H'. The %c format specifier prints a single character.
Q.505Medium
A void pointer can be used to store addresses of variables of any data type. However, it must be cast before dereferencing. Which statement about void pointers is FALSE?
Answer: B
A void pointer cannot be directly dereferenced. It must be cast to the appropriate pointer type first.
Q.506Medium
Consider the code: int arr[] = {5, 10, 15, 20}; int *ptr = arr; ptr++; What does ptr now point to?
Answer: C
Pointer arithmetic increments by the size of the data type. For int (4 bytes), ptr++ moves to the next integer, which is arr[1].
Q.507Medium
Which of the following best describes a dangling pointer situation?
Answer: B
A dangling pointer occurs when it points to memory that no longer exists, typically after free() or when a local variable goes out of scope.
Q.508Medium
Consider: int x = 5; int *p = &x; int q = &p; What is the value of q?
Answer: A
q is a pointer to pointer p. **q dereferences twice: first to get p, then to get the value x, which is 5.
Q.509Medium
Which memory allocation function does NOT initialize allocated memory to zero?
Answer: D
malloc() and realloc() return uninitialized memory with garbage values. calloc() initializes all bytes to zero.
Q.510Medium
Consider: int arr[5] = {1, 2, 3, 4, 5}; int *p = arr; What is the value of *(p+2)?
Answer: B
p points to arr[0]. p+2 points to arr[2], and *(p+2) dereferences to the value at arr[2], which is 3.
Q.511Medium
A function needs to modify a variable in the calling function. Which parameter passing method is appropriate?
Answer: B
To modify a variable in the calling function, you must pass its address (pointer). Pass by value creates a copy and cannot modify the original.
Q.512Medium
Consider: void func(int *arr, int size); This function prototype suggests that func will:
Answer: B
Since an array pointer is passed, the function can access and modify the original array elements in the caller's scope.
Q.513Medium
What will be the output of: int x = 10; int *p = &x; printf("%p", p); (assuming typical system output)
Answer: B
The %p format specifier prints the pointer value as a memory address in hexadecimal format, not the dereferenced value.
Q.514Hard
In a function that returns a pointer, which of the following is UNSAFE?
Answer: B
Returning a pointer to a local variable is unsafe because the variable ceases to exist after the function returns, creating a dangling pointer.
Q.515Hard
Consider: int *p = (int *)malloc(5 * sizeof(int)); for(int i=0; i<5; i++) *(p+i) = i*10; Which statement correctly deallocates this memory?
Answer: B
malloc() allocated memory must be freed using free(p), not free(&p). After freeing, it's good practice to set p = NULL.
Q.516Hard
A programmer uses a pointer variable but forgets to initialize it before dereferencing. Which type of error will occur?
Answer: C
Uninitialized pointers contain garbage values. Dereferencing them accesses arbitrary memory locations, causing runtime errors or undefined behavior.
Q.517Easy
What is the size of a pointer variable in a 64-bit system?
Answer: A
In a 64-bit system, all pointers occupy 8 bytes regardless of the data type they point to.
Q.518Easy
What does the & operator do when used with a variable?
Answer: B
The & (address-of) operator returns the memory address of the variable.
Q.519Easy
What is the output of the following code? int x = 20; int *p = &x; printf("%d", *p);
Answer: B
The * operator dereferences the pointer p, accessing the value it points to, which is 20.
Q.520Easy
Which of the following is a void pointer?
Answer: B
void* is a generic pointer that can hold addresses of any data type and requires explicit typecasting when used.