+ 2
what is the output of this code
int b=2; int i=5; i + =++ i*b; cout<<i;
3 Answers
+ 2
i += ++i*b
is equivalent to
i = i + ++i * b
unary operators have higher precedence so ++i is evaluated first so i becomes 6
*has higher precedence next, so 6*2 is 12
then i + 12 since I has already been incremented to 6, 6+12=18 will be the result.
+ 3
actually 18
+ 1
18