Wyo C++ - Ch. 5 Worksheet #5 | Name - |
1. Identify each of the following as either a declaration statement
(D), an assignment statement (A), or a comment statement (C). Print the correct
letter (D, A, or C) to the left of each exercise.
a/ | apples = 50; | |
b/ | int dollars; | |
c/ | // John Doe | |
d/ | cost = 0.50 * apples; | |
e/ | double cost = 0.0; | |
f/ | // variable declarations | |
g/ | const double SALES_TAX = 0.06; |
2. Which data type - char, double, and int - would be the most
appropriate for a variable that would be used in a program to store.....
a/ | the quantity of apples purchased | |
b/ | the cost of a daily newspaper (in dollar units) | |
c/ | the number of people that live in New York City | |
d/ | the number of people that live on Earth | |
e/ | the letter grade that you expect to earn in this CMPSC 101 course | |
f/ | your future salary in $ | |
g/ | a constant used to store the number of hours in a day |
3. Write a single cout statement that would display your first and last name
separated by a single space on one line of output along with your phone number
on a second line of output. Do not use two cout statements.
4. Write a single assignment statement that would compute the number of bagels purchased and store that value in an int variable named totalBagels, assuming that the variable dozenBagels stores the number of dozens purchased.