+ 3
X++, ++x what different
X++, ++x what different
9 Answers
+ 14
x++ use x first then increment it whereas
++x first increment it then use it;
example
int x=0;
cout<<x++;
output is 0 and value of x becomes 1.
while for
int x=0;
cout<<++x;
output is 1 and value of x is also 1.
+ 9
x++ is a post increament- it will increment the after executing the expression.
ex- int a=1, b=2,c;
c=a++ + b++;
ans- now c=3
a=2 b=3
++x is pre increment -- it will increment the value first and after that execute expression.
int a=1,b=2,c;
c= ++a + ++b;
ans-- c= 5 a=2 b=3
+ 6
x++ use the number first and then increments it
++x increments the number and then use it
+ 4
I'll explain it with an example. If you have
var x=3;
y = 2 + x++;
document.write(y);
then y = 5. That's because "x++" means: "execute this line of code. Then increase of 1 the value of x".
So "y = 2 + x++" means: "First, I do 2+3. Then I put x=4".
++x does the same thing, but in the opposite order.
So
var x = 3;
y= 2 + ++x;
means: "First I increase x of 1 (x=4). Then I compute y=2+4=6"
+ 1
plz teach me php
+ 1
++x menace prefix expression
x++ menace postfix expression
++x is incremental first
x++ is after value incremental
+ 1
x=4, x++, x=5 after thr loop, ++x, x=5 before the loop
0
++x increment then use.first increase the value of x then use it to solve problem.
x++ use then increment. first solve the problem using x then increase it by 1 to find solution next time
- 5
X++ = X+1 ++X = 1+X