C Programming — Pointers
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 21–30 of 100 questions in Pointers
Q.21 Easy Pointers
How does free() handle a NULL pointer?
A Causes segmentation fault
B Does nothing (safe operation)
C Returns error code
D Undefined behavior
Correct Answer:  B. Does nothing (safe operation)
EXPLANATION

free(NULL) is safe in C and does nothing. This is by design to prevent errors when freeing pointers.

Take Test
Q.22 Medium Pointers
What is the purpose of the const keyword in: int * const p;?
A Pointer points to constant data
B Pointer itself is constant
C Both pointer and data are constant
D Data becomes read-only
Correct Answer:  B. Pointer itself is constant
EXPLANATION

const after * means the pointer address cannot change, but the data it points to can be modified.

Take Test
Q.23 Medium Pointers
In the expression: int arr[5]; int *p = arr; What does p + 2 represent?
A Address of arr[0] + 2 bytes
B Address of arr[2]
C Value 2
D Address of arr[0] + 8 bytes
Correct Answer:  B. Address of arr[2]
EXPLANATION

Pointer arithmetic scales by data type size. p + 2 moves 2 * sizeof(int) bytes forward, pointing to arr[2].

Take Test
Q.24 Medium Pointers
What is the difference between NULL and a wild pointer?
A NULL points to 0, wild is uninitialized
B Both are same
C NULL is a constant, wild can vary
D NULL is type-safe, wild is not
Correct Answer:  A. NULL points to 0, wild is uninitialized
EXPLANATION

NULL is explicitly set to address 0, while wild pointers contain garbage values from uninitialized memory.

Take Test
Q.25 Medium Pointers
Which operation is NOT allowed on void pointers in C without explicit casting?
A Assignment
B Arithmetic operations
C Dereferencing
D Passing to functions
Correct Answer:  B. Arithmetic operations
EXPLANATION

Void pointers cannot perform pointer arithmetic (++, --, +n) directly. They must be cast to a specific type first.

Take Test
Q.26 Medium Pointers
Consider the code: int x = 10; int *p = &x; int **q = &p; What is the value of **q?
A 10
B Address of x
C Address of p
D Undefined
Correct Answer:  A. 10
EXPLANATION

q points to p, p points to x. **q dereferences twice: first gets p's value (address of x), second gets x's value (10).

Take Test
Q.27 Easy Pointers
What is the size of a pointer in a 64-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D 16 bytes
Correct Answer:  C. 8 bytes
EXPLANATION

In 64-bit systems, pointers are 8 bytes (64 bits) regardless of the data type they point to.

Take Test
Q.28 Easy Pointers
Which of the following correctly declares a pointer to a pointer?
A int **ptr;
B int *&ptr;
C int &&ptr;
D int ***ptr;
Correct Answer:  A. int **ptr;
EXPLANATION

Double pointer (int **ptr) is the correct syntax for pointer to pointer. Single & is used in C++ references, not C.

Take Test
Q.29 Medium Pointers
What is the output?
int arr[] = {10, 20, 30};
int *p = arr;
printf("%d", sizeof(p));
A 12
B 8 or 4 depending on system
C 3
D Compilation error
Correct Answer:  B. 8 or 4 depending on system
EXPLANATION

p is a pointer, so sizeof(p) returns pointer size (8 bytes on 64-bit, 4 on 32-bit), not array size.

Take Test
Q.30 Hard Pointers
What is the difference between arr and &arr if arr is an array?
int arr[5];
A Both are identical
B arr is pointer to first element, &arr is pointer to whole array
C &arr is pointer to first element, arr is pointer to whole array
D They have different sizes
Correct Answer:  B. arr is pointer to first element, &arr is pointer to whole array
EXPLANATION

arr decays to pointer to first element (int*). &arr is pointer to whole array (int(*)[5]). Pointer arithmetic differs.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips