+ 3

About x++, x+

can someone plz tell me what's the difference between x+ and x++?

12th Dec 2016, 3:15 AM
Nabeer
Nabeer - avatar
3 Answers
+ 2
9 :) I guess
13th Dec 2016, 5:56 AM
Nabeer
Nabeer - avatar
- 1
when u encounter ++x, first increase x value with 1 then do any operations on that statement . hence called pre increment. when u encounter x++, first perform operations on that statement for x without bothering about increment but after that statement x value will be increment by 1. hence post increment example: x=5; y=++x + x++; y will be 12 as y=6 + 6 but after this statement x becomes 7 now answer this int x=6; int y=++x - x++ + ++x; cout<<y; cout<<x;
12th Dec 2016, 4:26 AM
Morpheus
Morpheus - avatar
- 1
y=7-7+8 so y= 8 and thrice increment on x makes it 9
13th Dec 2016, 5:58 AM
Morpheus
Morpheus - avatar