Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function 1 printDottedLine: Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to standard output

 Function 1 – printDottedLine:

  1. 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.
  2. Write a statement that calls printDottedLine.
  3. Write a statement that declares a prototype for the function printDottedLine, which has no parameters and doesn't return anything.
  4. Move the function printDottedLine definition after the main function, compile it until it is error free and runs correctly to produce the correct output.

B. Function 2 – printErrorDescription

  1. Write a statement that declares a prototype for a function printErrorDescription, which has an int parameter and returns nothing.
  2. Write the definition of a function printErrorDescription, which has an int parameter and doesn't return anything. The function prints an “error message” if the number 14 is passed to it. If any other number is passed to it, it prints “success”.
  3. Write a statement that calls the function printErrorDescription, passing it the value 14.
  4. Write a statement that calls the function printErrorDescription, passing it the value 10.

C. Function 3 – printLarger

  1. 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.

  1. Write a statement that declares a prototype for a function printLarger, which has two int parameters and returns no value.
  2. Write the definition of a function printLarger, which has two int parameters and returns nothing. The function prints the larger value of the two parameters to standard output on a single line by itself. (For purposes of this exercise, the "larger" means "not the smaller".)

D. Function 4 – printGrade

  1. 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

E. Function 5 - printAttitude

  1. 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.

2. Write a prototype for the function and a statement that calls the function.

F. Function 6 – dashedLine

  1. Write the definition of a function dashedLine, with one parameter, an int.

If the parameter is negative or zero, the function does nothing. Otherwise it prints a complete line terminated by a new line character to standard output consisting of dashes (hyphens) with the parameter's value determining the number of dashes. The function returns nothing.

2. Write a prototype for the function and a statement that calls the function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here are the requested functions and statements A Function 1 printDottedLine include Function protot... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions