- 1
[SOLVED] what is the output for the following codes
int a=3; int b=2; b=a++; cout<<++b;
6 Respostas
+ 2
a=3, b=2
b=a++; <==> b=a; a+=1;// b=3, a=4
++b; <==> b+=1;// b=4
+ 2
answer is 4
You can also run it to see it's solution.....
I didn't see any problem in that....
+ 1
4
+ 1
that was my updated answer
+ 1
woops sorry Loai
0
b=a++// this is post increment which means that b equal to a, then add 1 to a.. so b=3
cout<<++b; // this is pre increment which means add one first then print it to screen.(3+1=4)