0

Help me guys

whats the difference between ++x and x++

12th Feb 2017, 4:49 AM
MR.EnDy
MR.EnDy - avatar
4 Answers
+ 4
int a = 2; int b = ++a; // this will give b the value of 3 and a will be 3 too int b = a++; // this will give b the value of 2 and then increment a so it will be 3
12th Feb 2017, 4:55 AM
Kawaii
Kawaii - avatar
+ 3
Help yourself first,LoL
12th Feb 2017, 5:37 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
help me giys i need help
12th Feb 2017, 4:49 AM
MR.EnDy
MR.EnDy - avatar
0
++x: x will be increased by 1 BEFORE performing this line of code; x++: x will become x+1 AFTER running this line of code. Example: int x=1; int y; y=x++; cout<<x<<" "<<y<<endl; y=++x; cout<<x<<" "<<y<<endl; //the first line of output will be 2 1 //the second line will be 3 3
12th Feb 2017, 6:27 AM
Yang Lu
Yang Lu - avatar