What will be printed out as a result of the following code execution?

#include <iostream>
using namespace std;

int main() {
    int a = 3;
    int b = 4;
    int c = 5;
    int &d = b;

    a = b = c;

    cout << a << b << c << d << endl;
    
    return 0;
}
Explanation
Assignment is performed from right to left -> a = b = c = 5 and d refers to b -> value of d coincides with the value of b.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes