Chapter 6 C++ GRADE A QUESTIONS WITH
SOLUTIONS
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)void printDottedLine()
{
cout << ".....\n";
}
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)void printGrade(char grade)
{
cout << "Grade: " << grade << "\n";
}
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)void printAttitude(int input)
{
switch(input)
SOLUTIONS
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)void printDottedLine()
{
cout << ".....\n";
}
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)void printGrade(char grade)
{
cout << "Grade: " << grade << "\n";
}
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)void printAttitude(int input)
{
switch(input)