Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 131–140 of 303
Topics in C Programming
Q.131 Easy Pointers
What is the output of the following code?
int x = 5;
int *p = &x;
int **q = &p;
printf("%d", **q);
A 5
B Garbage value
C Address of x
D Compilation error
Correct Answer:  A. 5
EXPLANATION

q is a pointer to pointer p. **q dereferences p twice, giving the value of x which is 5.

Take Test
Q.132 Easy Pointers
Which of the following is a void pointer?
A A pointer that points to nothing
B A generic pointer that can point to any data type
C A pointer declared as void variable
D A pointer that has been deleted
Correct Answer:  B. A generic pointer that can point to any data type
EXPLANATION

void* is a generic pointer that can hold addresses of any data type and requires explicit typecasting when used.

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

The * operator dereferences the pointer p, accessing the value it points to, which is 20.

Take Test
Q.134 Easy Pointers
What does the & operator do when used with a variable?
A Returns the value of the variable
B Returns the address of the variable
C Creates a copy of the variable
D Deallocates memory
Correct Answer:  B. Returns the address of the variable
EXPLANATION

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

Take Test
Q.135 Easy Pointers
What is the size of a pointer variable in a 64-bit system?
A 8 bytes
B 4 bytes
C Depends on data type
D 16 bytes
Correct Answer:  A. 8 bytes
EXPLANATION

In a 64-bit system, all pointers occupy 8 bytes regardless of the data type they point to.

Take Test
Q.136 Easy Pointers
What will be printed by the code: char *ptr = "Hello"; printf("%c", *ptr);
A H
B Hello
C e
D Error
Correct Answer:  A. H
EXPLANATION

ptr points to the first character of the string, so *ptr dereferences to 'H'. The %c format specifier prints a single character.

Take Test
Q.137 Easy Pointers
Which operator is used to get the address of a variable?
A * (asterisk)
B & (ampersand)
C -> (arrow)
D . (dot)
Correct Answer:  B. & (ampersand)
EXPLANATION

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

Take Test
Q.138 Easy Pointers
Consider: int x = 10; int *p = &x; What does the expression *p represent?
A The address of x
B The pointer variable p
C The value stored in x
D The size of x
Correct Answer:  C. The value stored in x
EXPLANATION

The dereference operator (*) accesses the value at the address pointed to by p, which is the value 10.

Take Test
Q.139 Easy Pointers
What is the size of a pointer variable on a 32-bit system?
A 2 bytes
B 4 bytes
C 8 bytes
D Depends on the data type
Correct Answer:  B. 4 bytes
EXPLANATION

On a 32-bit system, all pointers are 4 bytes (32 bits) regardless of the data type they point to.

Take Test
Q.140 Easy Pointers
A pointer variable stores the _____ of another variable.
A value
B memory address
C data type
D size
Correct Answer:  B. memory address
EXPLANATION

Pointers store memory addresses of variables. The address-of operator (&) retrieves this address.

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