+ 1

What's the difference between the 2 codes?

I am getting different outputs. https://code.sololearn.com/c8XC2Z461UJu/?ref=app https://code.sololearn.com/cmxCCT4z52mN/?ref=app

29th Sep 2017, 2:01 PM
harsh.I.M.
harsh.I.M. - avatar
5 Respostas
+ 7
It's how we do it in maths when we assign variables also, my English isn't very good so I didn't know what else to say
29th Sep 2017, 2:20 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 6
For the 2nd one, I let int a = 0 and the output was the same though I dont know what the difference is... I have zero experience in CPP
29th Sep 2017, 2:05 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 4
Quite simply, one code is incrementing the variable a before printing, while the other is incrementing after printing. If you increment before you print, the variable will be larger than if you incremented after. This is because the variable was incremented.
29th Sep 2017, 5:26 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
thanks
1st Oct 2017, 7:53 AM
harsh.I.M.
harsh.I.M. - avatar
0
why let.
29th Sep 2017, 2:11 PM
harsh.I.M.
harsh.I.M. - avatar