Two or three of these questions will be used for an in-class quiz at the
end of the week. It's possible that the questions may be modified
slightly.
The function Sing below is from program bday2.cpp
in the book. If the name of the parameter is changed from
person to olderOne what line of the function
changes? How does it change?
void Sing(string person)
{
cout << "Happy birthday to you" << endl;
cout << "Happy birthday to you" << endl;
cout << "Happy birthday dear " << person << endl;
cout << "Happy birthday to you" << endl;
cout << endl;
}
Using the same function from the previous question show how to
call the function to print a complete verse, the third line of which is:
Happy birthday dear lovely person
The function body should not be modified at all.
Show a function main that prompts the user for a person to
sing happy birthday to, and then prints a verse of the program.
The expression below on the left evaluates to zero, explain why.
What is the value of the expression on the right? Why?
(73 - 32) * (5/9) 99 - 18.0 * 5 / 9
The statements below print 12 and 4. The user intends them to print 3
and 1. Add parentheses so that 3 and 1 are printed.
cout << (8 + 4)/2*2 << endl;
cout << (8 - 4)/2*2 << endl;
The function below is from pizza.cpp. Show how to modify
the function to take the thickness of a pizza into account (so that
volume is used rather than area).
void SlicePrice(int radius, double price)
// compute pizza statistics
{
// assume all pizzas have 8 slices
cout << "sq in/slice = ";
cout << 3.14159*radius*radius/8 << endl;
cout << "one slice: $" << price/8 << endl;
cout << "$" << price/(3.14159*radius*radius);
cout << " per sq. inch" << endl;
}