Stupid question from a beginner | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Stupid question from a beginner

Why a is 12 and b is 13? https://code.sololearn.com/WbRSnoR3y7Oi/?ref=app

4th Feb 2020, 12:27 PM
КОнь КонЮв
КОнь КонЮв - avatar
1 Respuesta
+ 7
You should know about pre and post increment, and pre and post decrement to understand your problem. a=13; b=a--; // here a value is first assigned to b then a is decremented, since it is a post decrement operation. So b will be 13. But now a is decremented so when you print, it will result in 12.
4th Feb 2020, 12:32 PM
Avinesh
Avinesh - avatar