Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

499 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 211–220 of 499
Topics in C Programming
Q.211 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.212 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.213 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.214 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.215 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.216 Medium Pointers
What is the output?
int x = 5;
int *const p = &x;
x = 10;
printf("%d", *p);
A 5
B 10
C Garbage value
D Compilation error
Correct Answer:  B. 10
EXPLANATION

const pointer p cannot be changed, but x can be modified. *p prints current value of x which is 10.

Take Test
Q.217 Medium Pointers
Which of the following is correct about pointer assignment?
int *p, *q;
p = q; // What happens?
A Copies the value p points to into q
B Makes p point to the same address as q
C Causes compilation error
D Allocates new memory for p
Correct Answer:  B. Makes p point to the same address as q
EXPLANATION

p = q copies the address stored in q to p. Now both point to same location.

Take Test
Q.218 Medium Pointers
What is the output?
int arr[2][3] = {{1,2,3}, {4,5,6}};
int *p = (int*)arr;
printf("%d", *(p+4));
A 5
B 4
C 6
D 1
Correct Answer:  A. 5
EXPLANATION

Array flattened: 1,2,3,4,5,6. p+4 points to 5th element which is 5.

Take Test
Q.219 Medium Pointers
Which pointer operation is NOT valid in C?
A int *p, *q; p - q (pointer subtraction)
B int *p; p++ (pointer increment)
C int *p, *q; p * q (pointer multiplication)
D int *p; *p = 5 (pointer dereference assignment)
Correct Answer:  C. int *p, *q; p * q (pointer multiplication)
EXPLANATION

Pointer multiplication is not allowed. Valid operations are addition, subtraction, increment, decrement, and comparison.

Take Test
Q.220 Medium Pointers
What is the output?
int a = 10;
int *p = &a;
int *q = p;
q = NULL;
printf("%d", *p);
A 10
B NULL
C Segmentation fault
D Garbage value
Correct Answer:  A. 10
EXPLANATION

q = NULL only changes q, not p. p still points to a, so *p prints 10.

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