+ 1
About ++x
What I have learned in C++ is that ++x is used to bring the same number that's listed just before. But while playing with an opponent the answer will be in favour of the one who adds 1 to x. eg. x=3 then ++x should be 3 is what I remember. But those who bring 4 will won.
8 Respuestas
+ 5
Tony Abraham Varughese There is no difference when used alone, the difference is when you use them in an expression.
X++ evaluates x, then increments it (post-incrementation).
++x increments x, then evaluates it (pre-incrementation).
Example:
int a = 1;
int b = a++; //b = 1, a = 2
System.out.println(b); //prints 1
a = 1;
b = ++a; //b = 2, a = 2
System.out.println(b); //prints 2
+ 3
Tony Abraham Varughese "++x" is same as "x=x+1".
So when x=3 then ++x would be 3+1=4.
+ 2
Arsenic Then there might not be any difference between ++x and x++
+ 1
Arsenic Expression; that's where I've stucked. Thanks
0
About operators:
http://www.cplusplus.com/doc/tutorial/operators
0
It is a type of pre increment operation . So, when it is used in any operation first increase the value then, go for airthmetic operation.
As for example;
x=5,y=9;
A=++x+y;
So, in this firstly x increase its value by one and then will add to y. A=6+9=15
0
Kaushal Kishore In your example x=5. But, I couldn't understand the logic that gives ++x=10
0
Oo sorry