CS 131 Chapter 3 Exercises 1. Errors: * Syntax (in C++ "grammar", detected during compilation). * Run-Time (the program is syntactically correct, but fails when running). * Logical (the program runs but produces incorrect output). 4. a. 3 b. 3.25 c. 1 d. 3.25 e. 3 f. syntax error (% only applies to int) 5. a. 13 b. 5 c. 32 d. 1 e. 6 f. 32 7. a. x -= 0.01 b. seconds += (60*minutes) c. Can't be rewritten with an arithmatic assignment operator since wages is not on the right side. 8. a. salary = salary + bonus b. seconds = seconds - 1 c. annual_int_rate = annual_int_rate / 100.0 d. total_cost = total_cost * (1.0 + SALES_TAX_RATE) 9. a. (x + y) / (2 * w) b. (5 * x - 3 * y) / 2 11. 13 7 14. The output will be: $9 80 116 15. The output will be: 1 Hi there. 2 Hi there. 3 Hi there. Bye now. 16. a. The output is: 4 Hi there. Bye now. The semicolon stops the loop after incrementing n three times. At the exit, n is 4 and is printed by the cout. b. The output is: 1 Hi 2 Hi 3 Hi there. Bye now. The loop only extends to the first line after the for. 17. Output: How many times: 3 Enter an int: 7 7 7 Enter an int: 12 12 19 Enter an int: 5 5 24