Question PRG-CPP-0003
EasyWhat is the output of this program?
#include <iostream>
using namespace std;
int main() {
int x = 1;
int &r = x;
r = 5;
cout << x;
return 0;
}
- A.
Error
- B.
0
- C.
Show answer and explanation
Answer: C
A reference is another name for x; changing r changes x.