0

Solve this

What is answer and why? int a=2; int b=3; while(--b) { ++a cout<<a ; }

27th Aug 2017, 3:20 PM
rahul negi
rahul negi - avatar
9 odpowiedzi
+ 6
Again, 34! I suggest you use a pen and paper and write down this program on it. Then trace the code flow and count how many times variable a is incremented.
27th Aug 2017, 3:28 PM
Babak
Babak - avatar
+ 5
Trace it my friend. BTW, your code have some syntax error.
27th Aug 2017, 3:32 PM
Babak
Babak - avatar
+ 5
int a=2; int b=3; while(--b) // first loop: b=2, a=3 // second loop: b=1, a=4 // third loop: b=0 and exit { ++a cout<<a ; }
27th Aug 2017, 3:37 PM
Babak
Babak - avatar
+ 5
Keep learning. Good luck.
27th Aug 2017, 3:40 PM
Babak
Babak - avatar
+ 4
Most likely my friend
27th Aug 2017, 3:39 PM
Babak
Babak - avatar
0
but answer is 5
27th Aug 2017, 3:30 PM
rahul negi
rahul negi - avatar
0
I got the same question in challenge bro
27th Aug 2017, 3:34 PM
rahul negi
rahul negi - avatar
0
so the challenge answer is wrong??
27th Aug 2017, 3:38 PM
rahul negi
rahul negi - avatar
0
thanks bruh
27th Aug 2017, 3:39 PM
rahul negi
rahul negi - avatar