GENERAL Quiz question

faye.w

Member
C++ Student
Hi there!

I cannot get the answer to this question and I don't know why it gives warning errors in VS, either.

double f=4.0;
f+=4.0+10.0/f+++5.0;

11.50

15.50

13.50

16.50


My thinking is:
- f++ = f+1=4+1=5
- 4+10/5+5=11
- f+=11 --> 4+11=15
Where did I get it wrong? Thank you!
 

faye.w

Member
C++ Student
@APalley

I just found this in the note! It says that "++" should take priority over "/"??

In the next table all of the operators of the C language are represented. The operators on the same line have the same priority.
1 () [] ->
2 ! ~ ++ -- + - * & (type) sizeof (unary +- and pointer *)
3 * / %
4 + -
5 << >>
6 < <= > >=
7 == !=
8 &
9 ^
10 |
11 &&
12 ||
13 ?:
14 = += -= *= /= %= &= ^= |= <<= >>=
15 ,
 
Last edited:
Top