0

Wt is difference between x++ and ++x

4th Mar 2018, 4:49 AM
Varsha
4 odpowiedzi
+ 14
this will help you to understand more about increment decrement https://www.sololearn.com/Discuss/407846/?ref=app
4th Mar 2018, 5:23 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 8
https://www.sololearn.com/learn/CPlusPlus/1610/?ref=app
4th Mar 2018, 5:58 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
Supoosing x=5 and we use x++, so that will use the current value of x(that is 5) and then after using it one time, it will add 1 to x.. so its value becomes 6. for example.. int y=x++; // y= 5 System.out.println(x); // prints 6 And if we use ++x, it just simply adds 1 to x, and then uses it, For example int y=++x // y= 6 System.out.println(x); // prints 6
4th Mar 2018, 5:51 AM
Aaron Stone
Aaron Stone - avatar
+ 1
x++ returns the current value of x then increments x by 1 ++x incrementa x by 1 then returns the new value int x = 0; int a = x++; // a is 0, x is 1 int b = ++x; // b is 2, x is 2
4th Mar 2018, 4:58 AM
Jesse Bayliss
Jesse Bayliss - avatar