+ 1

What is difference between ++× and ×++

31st Oct 2016, 8:15 AM
Yasir Ayaz Khan
Yasir Ayaz Khan - avatar
4 Answers
+ 13
int x=5; cout<<++x; //x=6 then outputs 6 x=5; cout<<x++;//outputs 5 then x=6 so ++x increment then use x++ use then increment
31st Oct 2016, 8:19 AM
Leo Flame
Leo Flame - avatar
+ 3
x++ Use the variable and afer that, it increase its value ++x Increase the value of the variable, after that use if Example 1 ---------- (Displays "Msg1, value of x=2") int x = 1; if (x++==1){ cout<<"Msg1, value of x="<<x; } else{ cout<<"Msg2values of x="<<x; } Example 2 ---------- (Displays "Msg2, value of x=2") int x = 1; if (++x==1){ cout<<"Msg1, value of x="<<x; } else{ cout<<"Msg2values of x="<<x; }
4th Nov 2016, 1:33 PM
Leruli Benavides
Leruli Benavides - avatar
+ 1
++x is prefix increment x++ is post increment
14th Nov 2016, 7:19 AM
veera
veera - avatar
0
use than change and change than use
7th Nov 2016, 5:22 PM
vikash srivastava
vikash srivastava - avatar