Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

1,000 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 421–430 of 1,000
Topics in C Programming
Q.421 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.

Test
Q.422 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.

Test
Q.423 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].

Test
Q.424 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.

Test
Q.425 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.

Test
Q.426 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).

Test
Q.427 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.

Test
Q.428 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.

Test
Q.429 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.

Test
Q.430 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.

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