Practice 25 Pointers multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: B — Variable storing address
A pointer is a variable that stores the memory address of another variable.
Show Answer & Explanation
Correct Answer: B — &
The address-of operator (&) returns the memory address of a variable.
Show Answer & Explanation
Correct Answer: B — *
The dereference operator (*) accesses the value stored at the address.
What will be the output?
int x = 10;
int *p = &x;
printf("%d", *p);Show Answer & Explanation
Correct Answer: B — 10
Pointer p stores address of x and *p gives the value of x.
What will be the output?
int x = 5;
int *p = &x;
*p = 8;
printf("%d", x);Show Answer & Explanation
Correct Answer: B — 8
Changing *p modifies the original variable x.
Show Answer & Explanation
Correct Answer: B — Pointer pointing to 0 address
NULL pointer does not point to any valid memory location.
Show Answer & Explanation
Correct Answer: D — Undefined behavior
Dereferencing NULL pointer leads to runtime error or crash.
Show Answer & Explanation
Correct Answer: B — Pointer not initialized
Wild pointer points to an unknown memory location.
What will be the output?
int a = 10;
int *p = &a;
printf("%d", *p + 1);Show Answer & Explanation
Correct Answer: B — 11
Dereferenced value 10 is incremented by 1.
What will be the output?
int arr[3] = {1,2,3};
int *p = arr;
printf("%d", *p);Show Answer & Explanation
Correct Answer: A — 1
Array name stores base address, so *p accesses first element.
What will be the output?
int arr[3] = {1,2,3};
int *p = arr;
printf("%d", *(p+1));Show Answer & Explanation
Correct Answer: B — 2
Pointer arithmetic moves pointer to next element.
Show Answer & Explanation
Correct Answer: B — Data type size
Incrementing pointer moves by size of data type.
What will be the output?
int x = 5;
int *p = &x;
p++;
printf("%d", *p);Show Answer & Explanation
Correct Answer: B — Garbage
Pointer moves to next memory location which is not valid for x.
Show Answer & Explanation
Correct Answer: C — void pointer
void pointer is a generic pointer type.
Show Answer & Explanation
Correct Answer: B — Type casting
Void pointer must be typecasted before dereferencing.
Show Answer & Explanation
Correct Answer: B — Pointer to freed memory
Dangling pointer points to memory that has been deallocated.
What will be the output?
int a = 10;
int *p = &a;
int **q = &p;
printf("%d", **q);Show Answer & Explanation
Correct Answer: B — 10
Pointer to pointer dereferences twice to get value.
Show Answer & Explanation
Correct Answer: B — int **p;
Double asterisk declares pointer to pointer.
What will be the output?
int arr[5];
printf("%d", sizeof(arr));Show Answer & Explanation
Correct Answer: C — 20
Array of 5 integers occupies 20 bytes (assuming 4 bytes each).
What will be the output?
int arr[5];
int *p = arr;
printf("%d", sizeof(p));Show Answer & Explanation
Correct Answer: D — Depends on compiler
Pointer size depends on system architecture (32-bit/64-bit).
Show Answer & Explanation
Correct Answer: B — Initializing pointer to NULL
Initializing pointers avoids accidental access.
Show Answer & Explanation
Correct Answer: B — Pointer stores address
Pointers store memory addresses.
What will be the output?
int x = 10;
int *p = &x;
printf("%d", sizeof(*p));Show Answer & Explanation
Correct Answer: B — 4
sizeof(*p) is size of int.
Show Answer & Explanation
Correct Answer: C — int &p;
Reference operator (&) is not valid in C.
What will be the output?
int a = 5;
int *p = &a;
printf("%d", (*p)++);Show Answer & Explanation
Correct Answer: A — 5
Post-increment prints value first, then increments.