C Programming — Pointers
C language from basics to advanced placement prep
28 Questions 10 Topics Take Test
Advertisement
Showing 1–10 of 28 questions in Pointers
Q.1 Easy Pointers
What is the primary issue with this code?
int *p;
*p = 10;
A Syntax error
B Pointer p is uninitialized and points to garbage memory
C The value 10 cannot be assigned through a pointer
D Missing return statement
Correct Answer:  B. Pointer p is uninitialized and points to garbage memory
EXPLANATION

p is declared but not initialized to point to any valid memory location. Dereferencing an uninitialized pointer causes undefined behavior.

Take Test
Q.2 Easy Pointers
Consider the declaration: const int *p; and int * const q;
Which statement is TRUE?
A Both p and q cannot be modified
B p points to a constant integer; q is a constant pointer to integer
C Both declarations are identical
D Both p and q can be modified freely
Correct Answer:  B. p points to a constant integer; q is a constant pointer to integer
EXPLANATION

const int *p means p can change but the data it points to cannot. int * const q means q cannot change but the data it points to can be modified.

Take Test
Q.3 Easy Pointers
What is the output of the following code?
int x = 10;
int *p = &x;
int **q = &p;
printf("%d", **q);
A 10
B Address of x
C Address of p
D Garbage value
Correct Answer:  A. 10
EXPLANATION

q is a pointer to pointer p. **q dereferences q twice: first to get p, then to get the value of x which is 10.

Take Test
Q.4 Easy Pointers
What happens with: int arr[10]; int *p = arr; *p = 5; printf("%d", arr[0]);?
A Prints garbage
B Prints 5
C Compiler error
D Prints 10
Correct Answer:  B. Prints 5
EXPLANATION

p points to arr[0]. *p = 5 modifies arr[0]. Printing arr[0] displays 5.

Take Test
Q.5 Easy Pointers
What is the result of: int x = 5; int *p = &x; int *q = p; if p == q?
A 0 (false)
B 1 (true)
C Undefined
D Compiler error
Correct Answer:  B. 1 (true)
EXPLANATION

Both p and q point to same address of x, so p == q evaluates to true (1).

Take Test
Advertisement
Q.6 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.7 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.8 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.9 Easy Pointers
What is the output?
char str[] = "ABC";
char *p = str;
printf("%c", *(p+2));
A A
B B
C C
D Null character
Correct Answer:  C. C
EXPLANATION

p+2 points to str[2] which is 'C'. Note: str[3] is null terminator.

Take Test
Q.10 Easy Pointers
What is the output?
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int x = 5, y = 10;
swap(&x, &y);
printf("%d %d", x, y);
A 5 10
B 10 5
C 10 10
D 5 5
Correct Answer:  B. 10 5
EXPLANATION

swap() exchanges values through pointers. x becomes 10, y becomes 5 after function call.

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