← Quiz: C++ Interview Questions: all 10 questions
Quiz: C++ Interview Questions · Question 4 of 10
What does this print? (code)
What does this print?
#include <iostream>
using namespace std;
int main() {
int x = 10;
int &y = x;
y++;
x *= 2;
cout << y;
return 0;
}
- A.10
- B.11
- C.22
- D.20
Answer & explanation
Correct answer: 22
y is x: 10 → 11 → 22.
Can you get the rest right without peeking?
Take the timed Quiz: C++ Interview Questions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →