why this code gives out 7 not 8? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
5th Aug 2022, 5:15 PM
Lakarov
Lakarov - avatar
3 Answers
+ 9
'cause when the operator is placed after the operand, it first returns the value of the operand and then increases the value of operand by 1. If you want 8, put increment operator before the operand. (++a)
5th Aug 2022, 5:37 PM
☆~Monu~☆
☆~Monu~☆ - avatar
+ 3
Because of the post increment. It returns the argument given and then adds 1 to it after
5th Aug 2022, 5:37 PM
Slick
Slick - avatar
+ 2
☆~Monu~☆ thank you!
5th Aug 2022, 5:38 PM
Lakarov
Lakarov - avatar