+ 1

Can somebody please explain how is the output 5 ??

int a=2; int b=3; while(b--) ++a; cout <<a;

22nd Apr 2017, 7:09 PM
Aniket Singh
1 Odpowiedź
+ 20
as long as "b" isnt "0" -> "a++" will be executed.... (the final value of "a" will be the initial sum of "a+b" (5) )
22nd Apr 2017, 7:12 PM
Valen.H. ~
Valen.H. ~ - avatar