C Programming

Pointers — Practice MCQs for CCAT

25 Questions Section B: Programming C Programming

Practice 25 Pointers multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.

Q1.
What is a pointer in C?
AVariable storing value
BVariable storing address
CFunction
DKeyword
Show Answer & Explanation

Correct Answer: B — Variable storing address

A pointer is a variable that stores the memory address of another variable.

Q2.
Which operator is used to get the address of a variable?
A*
B&
C#
D%
Show Answer & Explanation

Correct Answer: B — &

The address-of operator (&) returns the memory address of a variable.

Q3.
Which operator is used to access the value pointed by a pointer?
A&
B*
C->
D.
Show Answer & Explanation

Correct Answer: B — *

The dereference operator (*) accesses the value stored at the address.

Q4.

What will be the output?


int x = 10;
int *p = &x;
printf("%d", *p);
AAddress of x
B10
CGarbage
DError
Show Answer & Explanation

Correct Answer: B — 10

Pointer p stores address of x and *p gives the value of x.

Q5.

What will be the output?


int x = 5;
int *p = &x;
*p = 8;
printf("%d", x);
A5
B8
CGarbage
DError
Show Answer & Explanation

Correct Answer: B — 8

Changing *p modifies the original variable x.

Q6.
What is a NULL pointer?
APointer with garbage value
BPointer pointing to 0 address
CUninitialized pointer
DDangling pointer
Show Answer & Explanation

Correct Answer: B — Pointer pointing to 0 address

NULL pointer does not point to any valid memory location.

Q7.
What happens if a NULL pointer is dereferenced?
AReturns 0
BReturns garbage
CCompilation error
DUndefined behavior
Show Answer & Explanation

Correct Answer: D — Undefined behavior

Dereferencing NULL pointer leads to runtime error or crash.

Q8.
What is a wild pointer?
APointer with value 0
BPointer not initialized
CPointer to pointer
DConstant pointer
Show Answer & Explanation

Correct Answer: B — Pointer not initialized

Wild pointer points to an unknown memory location.

Q9.

What will be the output?


int a = 10;
int *p = &a;
printf("%d", *p + 1);
A10
B11
CAddress
DError
Show Answer & Explanation

Correct Answer: B — 11

Dereferenced value 10 is incremented by 1.

Q10.

What will be the output?


int arr[3] = {1,2,3};
int *p = arr;
printf("%d", *p);
A1
B2
CAddress
DError
Show Answer & Explanation

Correct Answer: A — 1

Array name stores base address, so *p accesses first element.

Q11.

What will be the output?


int arr[3] = {1,2,3};
int *p = arr;
printf("%d", *(p+1));
A1
B2
C3
DGarbage
Show Answer & Explanation

Correct Answer: B — 2

Pointer arithmetic moves pointer to next element.

Q12.
Pointer arithmetic depends on:
AAddress size
BData type size
COS
DCompiler
Show Answer & Explanation

Correct Answer: B — Data type size

Incrementing pointer moves by size of data type.

Q13.

What will be the output?


int x = 5;
int *p = &x;
p++;
printf("%d", *p);
A5
BGarbage
C6
DCompilation error
Show Answer & Explanation

Correct Answer: B — Garbage

Pointer moves to next memory location which is not valid for x.

Q14.
Which pointer can point to any data type?
Aint pointer
Bchar pointer
Cvoid pointer
DNULL pointer
Show Answer & Explanation

Correct Answer: C — void pointer

void pointer is a generic pointer type.

Q15.
What is required before dereferencing a void pointer?
ANothing
BType casting
CFree memory
DInitialization
Show Answer & Explanation

Correct Answer: B — Type casting

Void pointer must be typecasted before dereferencing.

Q16.
What is a dangling pointer?
AUninitialized pointer
BPointer to freed memory
CPointer with NULL
DPointer to array
Show Answer & Explanation

Correct Answer: B — Pointer to freed memory

Dangling pointer points to memory that has been deallocated.

Q17.

What will be the output?


int a = 10;
int *p = &a;
int **q = &p;
printf("%d", **q);
AAddress
B10
CGarbage
DError
Show Answer & Explanation

Correct Answer: B — 10

Pointer to pointer dereferences twice to get value.

Q18.
Which of the following is correct declaration of pointer to pointer?
Aint *p;
Bint **p;
Cint p**;
Dint &p;
Show Answer & Explanation

Correct Answer: B — int **p;

Double asterisk declares pointer to pointer.

Q19.

What will be the output?


int arr[5];
printf("%d", sizeof(arr));
A4
B5
C20
DDepends on compiler
Show Answer & Explanation

Correct Answer: C — 20

Array of 5 integers occupies 20 bytes (assuming 4 bytes each).

Q20.

What will be the output?


int arr[5];
int *p = arr;
printf("%d", sizeof(p));
A4
B8
C20
DDepends on compiler
Show Answer & Explanation

Correct Answer: D — Depends on compiler

Pointer size depends on system architecture (32-bit/64-bit).

Q21.
Which is safer practice to avoid wild pointers?
AUsing free()
BInitializing pointer to NULL
CUsing goto
DUsing static
Show Answer & Explanation

Correct Answer: B — Initializing pointer to NULL

Initializing pointers avoids accidental access.

Q22.
Which statement is true?
APointer stores value
BPointer stores address
CPointer stores instruction
DPointer stores constant
Show Answer & Explanation

Correct Answer: B — Pointer stores address

Pointers store memory addresses.

Q23.

What will be the output?


int x = 10;
int *p = &x;
printf("%d", sizeof(*p));
A2
B4
C8
DDepends on compiler
Show Answer & Explanation

Correct Answer: B — 4

sizeof(*p) is size of int.

Q24.
Which of the following is invalid?
Aint *p;
Bint **p;
Cint &p;
Dint *p = NULL;
Show Answer & Explanation

Correct Answer: C — int &p;

Reference operator (&) is not valid in C.

Q25.

What will be the output?


int a = 5;
int *p = &a;
printf("%d", (*p)++);
A5
B6
CGarbage
DError
Show Answer & Explanation

Correct Answer: A — 5

Post-increment prints value first, then increments.