+ 2
someone should tell me how it works, with full description đ·
int x = 4 int y = 3 cout << ++x*y-- ; output: 15
12 Answers
+ 15
first will execute ++x --> x = 5
second will execute x*y --> 5*3 = 15
third will print the result "15"
forth will ecexute y-- --> y = 2
+ 14
this is the order in which it all happens:
1) ++x increments x from 4 to 5
2) x*y -> 5*3 = 15
3) y-- decrease y to 2 (the calculation in 2 has already been made so that is the final output)
4) if you were to check the value of y you'd see it is now 2
+ 13
thanks guys helpful for me too...
+ 12
it works after the execution of the expression.
ex:
int x = 4;
int y = 3;
cout << ++x*y--; // will output 15
cout << y;
// now value of y change and will output 2
+ 11
with prefix ++x will increment x by 1 then execute the expression, while in postfix y-- will execute the expression then decrement the value of y by 1.
+ 11
int x = 5;
int y = 3;
cout << ++x*y--;
it shows 18 not 15
but if you mean
cout << x++ * y--;
it will shows 15
+ 11
you'r welcome..
+ 11
you'r welcome..đ
+ 3
you mean there is no work for '--'?
+ 1
all right but what's about that?
int x = 5
int y = 3
cout << ++x*y--;
it also shows 15?
+ 1
yup, clearđ thanks Dakdoukđ
+ 1
int x = 5;
int y = 3;
cout << ++x*y--;
it shows 18 not 15//can you please explain why is it 18... does it mean only value of x was incremented
but if you mean
cout << x++ * y--;// and here why is it 15
it will shows 15