+ 1

What is the output of the question with explanation?

int a=20; int &n=a; n=a++; a=n++; cout<<a<<","<<n;

2nd Jan 2019, 6:05 PM
Aacharan Jain
Aacharan Jain - avatar
3 Answers
+ 2
You using reference From now on, you can use both of these variables interchangeably. The following assignments will give the same effect: n = a++; 20 = 20; a = n++; 21 = 20; So, now a is equals 20 the same as n.
2nd Jan 2019, 8:38 PM
Izaak GOLDSTEIN
Izaak GOLDSTEIN - avatar
2nd Jan 2019, 8:42 PM
Izaak GOLDSTEIN
Izaak GOLDSTEIN - avatar
0
n =a++ in this line a post increment bcoz n is reference type then both value are 21 na Why 20 20
3rd Jan 2019, 3:42 AM
Aacharan Jain
Aacharan Jain - avatar