?
Which of the following operator(s) can be used with pointers?
Which of the following operator(s) can be used with pointers?
i. – only
ii. +, *
iii. +, –
iv. +, -, *
v. /
vi. + only
Answer & Solution
Correct Answer:
Option
A
Explanation:
Pointers in C++ are variables that hold memory addresses. They're like street addresses that tell you where a house (data) is located.
We use special operators to work with these memory addresses.
+ (Addition): We can add a number to a pointer to move it to a different memory location. Imagine walking a few houses down the street.
- (Subtraction): Similarly, we can subtract to move backward in memory (go back a few houses).
* (Dereference): This is the most important pointer operator. It lets us access the data stored at the memory address held by the pointer. Think of it like going inside the house to see what's there.
The division operator (/) is not directly used with pointers in the same way as addition, subtraction, or dereference.
Therefore, the correct options are addition (+), subtraction (-), and dereference (*).
So the answer is (D) iv
Pointers in C++ are variables that hold memory addresses. They're like street addresses that tell you where a house (data) is located.
We use special operators to work with these memory addresses.
+ (Addition): We can add a number to a pointer to move it to a different memory location. Imagine walking a few houses down the street.
- (Subtraction): Similarly, we can subtract to move backward in memory (go back a few houses).
* (Dereference): This is the most important pointer operator. It lets us access the data stored at the memory address held by the pointer. Think of it like going inside the house to see what's there.
The division operator (/) is not directly used with pointers in the same way as addition, subtraction, or dereference.
Therefore, the correct options are addition (+), subtraction (-), and dereference (*).
So the answer is (D) iv
Join the Discussion
Login to post a comment or share your explanation.
Login