Ch. 3 Exercises
Hi all, I think the answer in the appendix to exercise 3.5 is incorrect.
Question:
By considering operator precedence, list the steps involved in the computation of the following expression:
resultVar += var1 * var2 + var3 % var4 / var5;
The precedence shown using parentheses in Appendix A is:
resultVar += (((var1 * var2) + var3) % (var4 / var5));
I believe the answer should be:
resultVar + ((var1 * var 2) + ((var3 % var4) / var5))
To me it seems as though the answer in the appendix gives preference to an addition operation over the % operation which is incorrect. It's late at night so I might just be sleepy, but feel free to take a look.
