🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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;
}
  1. A.10
  2. B.11
  3. C.22
  4. 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 →