• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

Chapter 6 C++

Document preview thumbnail
Preview 2 out of 7 pages

Exam of 7 pages for the course Chapter 6 C++ at Chapter 6 C++ (Chapter 6 C++)

Content preview

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)

Document information

Uploaded on
October 26, 2024
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
douglasmugwe82
5.0
(1)
Sold
2
Followers
0
Items
4215
Last sold
1 year ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions