int i=7,*p=&i,&r=i;
i=5;
output after the statement cout<<i<<“ ”<<*p<<“ ”<<r; would be
- AOption (a)
577
- BOption (b)
555
- COption (c)
777
- DOption (d)
755
View answer & explanationHide answer & explanation
Correct answer
555
Why this answer is correct
The correct answer is : option 2
Key Points
Code:
int i = 7; int *p = &i; int &r = i;
i = 5;
cout << i << " " << *p << " " << r;
Step-by-Step Explanation:
- int i = 7; → Variable i is initialized to 7.
- int *p = &i; → Pointer p holds the address of i.
- int &r = i; → r is a reference to i.
- i = 5; → Value of i is changed to 5.
Now, evaluate the output:
- i → 5
- *p → dereferencing pointer to i → 5
- r → reference to i → 5
Final Output: 5 5 5
Correct Answer: Option 2) 555 ✅