+ 1
What is the difference?
What is the difference between a++ and ++a?
3 Antworten
+ 5
a++ is post increment and ++a is pre increment.
Say,a=5
y=++a
Answer:
y=6
a=6
Whereas,
y=a++
Answer:
y=5
a=6
+ 2
For instance we have a integrer (variable) named a and is equal to 5. So, if we write y=++x, both y and x gets equal to 6, but if we write y=x++, y takes the value 5 and x = 6. In the first case, x is increased by 1 before is assigned to y, while this doesn't happen in the second one (y=x and then x=x+1). Understood?
+ 1
Yep👍
Thanks! !