Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 131–140 of 291
Topics in C Programming
Q.131 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.

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

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

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

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

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

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

Test
Q.138 Easy Pointers
Identify the output:
char *str = "Hello";
printf("%c", *str);
A H
B Hello
C e
D Address
Correct Answer:  A. H
EXPLANATION

*str dereferences the pointer to get the first character of the string, which is 'H'.

Test
Q.139 Easy Pointers
Which of the following is NOT a valid pointer declaration?
A int *p;
B float *q;
C void *r;
D int &s;
Correct Answer:  D. int &s;
EXPLANATION

& is a reference operator used in C++, not in C. In C, pointers are declared using *.

Test
Q.140 Easy Pointers
What is a NULL pointer?
A Pointer pointing to address 0
B Uninitialized pointer
C Pointer with no name
D Invalid pointer
Correct Answer:  A. Pointer pointing to address 0
EXPLANATION

A NULL pointer is a pointer that points to memory address 0, indicating it doesn't point to any valid memory location.

Test
IGET
IGET AI
Online · Exam prep assistant
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