What is the output of the following code? int a=3; int b=2; b=a++; cout<<++b; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the output of the following code? int a=3; int b=2; b=a++; cout<<++b;

18th May 2017, 1:49 PM
RAYUTH
RAYUTH  - avatar
4 Answers
+ 6
int a=3; int b=2; b=a++; // b is 3 and a is 4 cout<<++b; // b is 4 because preincrement
18th May 2017, 2:19 PM
Setiawan Next
Setiawan Next - avatar
+ 5
4 lol
18th May 2017, 2:21 PM
Xander A.
Xander A. - avatar
+ 1
4
17th Apr 2020, 6:10 PM
Alfie Nyats
Alfie Nyats - avatar
0
4
18th May 2017, 2:32 PM
Mark