7. Suppose that there are two variables: x and y. x stores “Beer” and y stores
“Water.” How can you swap the values of the two variables to let x store
“Water” and y store “Beer”?
8. Suppose that there are three variables: Purchase, TaxRate, and Payment.
Purchase stores the money value of the purchased merchandise, and
TaxRate stores the state sales tax rate. Write an arithmetic operation to let
Payment store the payment amount after tax.
9. Write an if-then-
else
statement using structured English for the GPA
scheme: Grade “A” = 4.0 points, grade “B” = 3.0 points, grade “C” = 2.0 points,
grade “D” = 1.0 point, and grade “F” = 0 points.
10. Write a loop statement using structured English to let the computer list 0.3,
0.6, 0.9, 1.2, 1.5, …, 30.
Chapter 2 Exercises
1. Read the following C program and complete it by filling in the blanks:
4 void main()
6 ____________ i;
7 double sales;