| CMPSC 101 - Variables Worksheet #4 | Name - |
1. Write a declaration statement that declares a double variable named salary.
2. Write an assignment statement that assigns the value 30000.56 to a variable named salary.
3. Write an assignment statement that adds 1000 to a variable named salary. For full credit, use the compound operator += .
4. In the right margin, show what output the following program would display:
#include <iostream>
using namespace std;int main()
{
int apples = 9;
double priceApples = 0.50;
const double APPLE_TAX = 0.05;
int totalPrice = 0;
totalPrice = apples * priceApples + apples * priceApples * APPLE_TAX;
cout << "Total is " << totalPrice << endl;
return 0;
} // end of main
5. What does the following expression simplify to? 5 + 13 % (10 / 2)
6. What is the final value of round after the execution of the following code?
double initial = 5.9;
round = int (initial);