- 1

B++is b=b+1 then I want to understand ++b what is it??

14th Oct 2016, 3:23 PM
Chandan Jha
Chandan Jha - avatar
2 Answers
+ 4
b++ and ++b are equivalent if used alone. The difference is when you use them in an expression. ++b increments b, then is evaluated (pre-increment) b++ is evaluated, then increments b (post-increment) Example: int a, b; b = 1; a = ++b; //a = 2, b = 2 b = 1; a = b++; //a = 1, b = 2
14th Oct 2016, 3:31 PM
Zen
Zen - avatar
+ 1
it's the same, b=b+1 But x=y+(b++) you use b and then increment it: x=y+b then b=b+1 x=y+(++b) you first increment b, and then you use it: b=b+1 then x=y+b
14th Oct 2016, 3:33 PM
marcram