+ 3

X++, ++x what different

X++, ++x what different

28th Nov 2016, 4:28 AM
HA.AFRATH SUJA
HA.AFRATH SUJA - avatar
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.
28th Nov 2016, 6:23 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 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
2nd Jan 2017, 2:22 AM
zixan sidd
zixan sidd - avatar
+ 6
x++ use the number first and then increments it ++x increments the number and then use it
30th Dec 2016, 1:31 PM
KavyaOleti
KavyaOleti - avatar
+ 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"
28th Nov 2016, 6:35 AM
Danilo Riccio
Danilo Riccio - avatar
+ 1
plz teach me php
30th Dec 2016, 4:42 PM
omax
omax - avatar
+ 1
++x menace prefix expression x++ menace postfix expression ++x is incremental first x++ is after value incremental
1st Jan 2017, 11:01 AM
Rushikesh Sulakhe
Rushikesh Sulakhe - avatar
+ 1
x=4, x++, x=5 after thr loop, ++x, x=5 before the loop
1st Jan 2017, 12:31 PM
Asuquo Ulo
Asuquo Ulo - avatar
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
9th Jan 2017, 8:21 PM
Kashish Gupta
Kashish Gupta - avatar
- 5
X++ = X+1 ++X = 1+X
28th Nov 2016, 6:47 AM
Ian
Ian - avatar