+ 1

Someone explain this to me properly

a =2 b=3 b=a++ cout<<++b;

23rd May 2017, 10:44 AM
Lovesh Verma
Lovesh Verma - avatar
5 Answers
+ 3
Thanks I just got it. b=3 a=2 b=a++ /* what it did is as a++ is postfix b=a // b = 2 a=a+1 //a=3 */ and when cout<<++b; /* it incremented b and then printed it as prefix does i.e: it printed +1 + b // print = 1+b //where b is 2 as above code. therefore, print(output) = 3 //3 is output */ I have explained it to others and thanks man
23rd May 2017, 11:06 AM
Lovesh Verma
Lovesh Verma - avatar
+ 1
a =2 b=3 b=a++ // b is 2 and a is 3 cout<<++b; // b is 3
23rd May 2017, 10:54 AM
Setiawan Next
Setiawan Next - avatar
+ 1
Just explain me breifly what happened when I did '++b'
23rd May 2017, 10:55 AM
Lovesh Verma
Lovesh Verma - avatar
+ 1
it add 1 to b a++ mean assign first add 1 later ++b mean add 1 first
23rd May 2017, 11:00 AM
Setiawan Next
Setiawan Next - avatar
+ 1
you are welcome
23rd May 2017, 11:20 AM
Setiawan Next
Setiawan Next - avatar