Why single variable increment and decrement not supporting in one statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Why single variable increment and decrement not supporting in one statement?

Ex print(--5++)

25th Jan 2017, 9:59 AM
Ramesh Papaganti
Ramesh Papaganti - avatar
2 Answers
+ 2
you can still use var a = 5; alert (--a); a++
25th Jan 2017, 10:11 AM
Kamil
Kamil - avatar
0
print (--5++) returns 4 this is because ++x and --x in-/de- crements the number, before returning it. example: x=5 print (--x) would output 4 on the other hand x++ and x-- in-/de- crements after returning the number. Therefore x=5 print (x++) outputs 5 then increments so if you then do print (x) it now outputs 6 so x=5 print (--x++) = 4 print(x) = 5
25th Jan 2017, 10:58 AM
Mini