0
Different incremental variable.
Please I'm kinda confused with these incremental variables: x++, ++x, x+=1. Do theyean the same thing, how do they differ if they do?
6 Réponses
+ 3
All three produesd same answer
+ 1
They all just add by one. The only difference is that x++ and ++x have different precedence.
+=some number identifies what to increment by. Because this case it's one it is equivalent to x++
In conclusion, x is added by one on all three cases making the answer of three on all of them Marvellous Abia
0
x++ takes the variable x first and then increments it by 1
++X increments by 1 first and then checks x
x+=1 basically means x=x+1. That states that the variable will be incremented by itself by 1 (in this case it's equivalent to x++). The 1 can be changed here to increment by different amounts
Hope this helps :)
0
Sumit Programmer😎😎, Minerals2016 .
Please what will the following evaluate to:
x=2
x++
print x
x = 2
++x
print x
x=2
x+=1
print x