and CORRECT Answers
printTodaysDate is a function that accepts no parameters and returns no value.
Write a statement that calls printTodaysDate. - CORRECT ANSWER - printTodaysDate();
Write the definition of a function printDottedLine, which has no parameters and doesn't return
anything. The function prints to standard output a single line (terminated by a new line character)
consisting of 5 periods. - CORRECT ANSWER - 1. void printDottedLine()
2. {
3. cout<<"....."<<endl;
4. }
Write a statement that declares a prototype for a function printTodaysDate, which has no
parameters and doesn't return anything. - CORRECT ANSWER - void printTodaysDate();
printErrorDescription is a function that accepts one int parameter and returns no value.
Write a statement that calls the function printErrorDescription, passing it the value 14. -
CORRECT ANSWER - printErrorDescription(14);
printLarger is a function that accepts two int parameters and returns no value.
Two int variables, sales1 and sales2, have already been declared and initialized.
Write a statement that calls printLarger, passing it sales1 and sales2. - CORRECT
ANSWER - printLarger(sales1, sales2);
Write a statement that declares a prototype for a function printErrorDescription, which has an int
parameter and returns nothing. - CORRECT ANSWER - void printErrorDescription(int);
Write a statement that declares a prototype for a function printLarger, which has two int
parameters and returns no value. - CORRECT ANSWER - void printLarger(int,int);
, Write the definition of a function printGrade, which has a char parameter and returns nothing.
The function prints on a line by itself the message string Grade: followed by the char parameter
(printed as a character) to standard output. Don't forget to put a new line character at the end of
your line.
Thus, if the value of the parameter is 'A', the function prints out Grade: A - CORRECT
ANSWER - 1. void printGrade(char c)
2. {
3. printf("Grade:%c\n",c);
4. }
Write the definition of a function printAttitude, which has an int parameter and returns nothing.
The function prints a message to standard output depending on the value of its parameter.
If the parameter equals 1, the function prints disagree
If the parameter equals 2, the function prints no opinion
If the parameter equals 3, the function prints agree
In the case of other values, the function does nothing.
Each message is printed on a line by itself. - CORRECT ANSWER - 1. void
printAttitude(int a)
2. {
3. switch(a)
4. {
5. case 1:cout<< "disagree"<<endl;break;
6. case 2:cout<< "no opinion"<<endl;break;
7. case 3:cout<< "agree"<<endl;break;
8. }
9. }