+ 2
Can somebody explain in detail how you get this calculation to 4? Iām a beginner thanks.
Int a = 3; Int b = 2; B = a++; Cout << ++b;
3 Answers
+ 11
Axel Inga
first a=3 b=2 then in the next line
b=a++ here a++ follows first use then change rule (post increment operator) so b=3
then cout<<++b here it follows change then use rule (pre increment operator) so it changes b from 3 to 4.
+ 8
Axel Inga Right šš
+ 2
Mohammad, thank you for your help. What i seam to not understand is this:
b=2 (we ignore this value right?)
b=a++ (so here it gets the same value as āaā which is 3. Right? Than, add one more because of the ++, and that would leave it to 4)
I know im wrong there, but thats how i see it and i cant seam to see it the right way. I understand the rest of the code.