Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3 Using Arithmetic Operators and Operator Precedence Expression Result 1.20 % (4

ID: 3888631 • Letter: 3

Question

3 Using Arithmetic Operators and Operator Precedence

Expression

Result

1.20 % (4 - 2)

2.20 / 4.0 * 6.4 / 2

3.4 % 5

4.3.0 * (6 / 24)

5.3 – (3 + 3.0) * 10 / 3

6.12.0 % 4

7.7 * 6 / 21 / 3.0

8.11 % 4 * 3.0

9.17 % 4 / 3

10.5 % 6 / 4

11.5 / 4.0 * 5

12.6 + 2 / 4

13.(2 - 3 + (2 * (3 / 3) % 1))

14.5 % 4

15.5 – (2.0 + 5) * 10 / 2

16.static_cast<float>(4)/3

17.static_cast<int>(3.7)+5.3

18.static_cast<int>(3.7+5.3)

19.static_cast<double>(5/2)

20.static_cast<char>(65)

Expression

Result

1.20 % (4 - 2)

2.20 / 4.0 * 6.4 / 2

3.4 % 5

4.3.0 * (6 / 24)

5.3 – (3 + 3.0) * 10 / 3

6.12.0 % 4

7.7 * 6 / 21 / 3.0

8.11 % 4 * 3.0

9.17 % 4 / 3

10.5 % 6 / 4

11.5 / 4.0 * 5

12.6 + 2 / 4

13.(2 - 3 + (2 * (3 / 3) % 1))

14.5 % 4

15.5 – (2.0 + 5) * 10 / 2

16.static_cast<float>(4)/3

17.static_cast<int>(3.7)+5.3

18.static_cast<int>(3.7+5.3)

19.static_cast<double>(5/2)

20.static_cast<char>(65)

Explanation / Answer

1. 20%(4-2) = 20%2 = 0

2. 20/4.0*6.4/2 = 5.0*6.4/2 = 32.0/2 = 16.0

3. 4%5 = 4

4. 3.0*(6/24) = 3.0*0 = 0 Note: [6/24 = some number less than 1, int value is 0]

5. 3 - (3+3.0)*10/3 = 3-6.0*10/3 = 3-60.0/3 = 3-20.0 = -17.0

6.   12.0 %4 = error, modulus operator is not defined for floating value

7. 7*6/21/3.0 = 42/21/3.0 = 2/3.0 = 0.666667

8. 11%4/3 = 3/3 = 1

9. 17%4/3 = 1/3 = 0

10. 5%6/4 = 5/4 = 1

11. 5/4.0*5 = 1.25 * 5 = 6.25

12. 6+2/4 = 6 + 0 = 6

13. (2-3+(2*(3/3)%1)) = (2-3+(2*1%1)) = (2-3+(2%1)) = (2-3+2) = 1

14. 5%4 = 1

15. 5 - (2.0+5)*10/2 = 5-7.0*10/2 = 5-70.0/2 = 5 - 35.0 = -33.0

16. static_cast<float>(4)/3 = 4.0/3 = 1.333333

17. static_cast<int>(3.7)+5.3 = 3+5.3 = 8.3

18. static_cast<int>(3.7+5.3) = static_cast<int>(9.0) = 9

19. static_cast<double>(5/2) = static_cast<double>(2) = 2.0

20. static_cast<char>(65) = 'A'