Question: Q1) Type in the below program including your name and date as a comment. Before running the program, change each of the question marks to

Q1) Type in the below program including your name and date as a comment. Before running the program, change each of the question marks to the numbers 1 through 5 indicating the order in which that line will be executed. Run the program and check your numbers. Fix and rerun if necessary.

#include

using namespace std;

//prototypes

void DemonstrateFunc1();

void DemonstrateFunc2(int num);

int main()

{

cout << "?. Execution starts with main. " << endl;

DemonstrateFunc1();

cout << "?. Then we come here. " << endl;

DemonstrateFunc2(100);

cout << "?. Finally we come here. "<< endl;

return 0;

}

//****************************

void DemonstrateFunc1()

{

cout << "?. This is a sample function." << endl;

}

//****************************

void DemonstrateFunc2(int num)

{

cout << "?. This is another sample function. " << endl;

cout << " num is an argument or parameter. " << endl;

cout << " The value of num is " << num << endl;

}

Submit a copy of the program and a copy of the program output.

Q2)

//**************************************************

// NewWelcome program

// This program prints a "Welcome Home" message

//**************************************************

#include

using namespace std;

void PrintLines( int ); // Function prototype

int main()

{

PrintLines(2);

cout << " Welcome Home!" << endl;

return 0;

}

//****************************************************************

// PrintLines prints lines of asterisks, where

// numLines specifies how many lines to print

//***************************************************************

void PrintLines( int numLines )

{

int line; // Loop control variable

for (line = 0; line < numLines; line++)

{

cout << "*************************************" << endl;

}

}

Type in the above program as lines.cpp. Add a comment to include your name and date. Compile and run. Change the program so that it will print 2 lines of asterisks before the welcome message and 4 lines of asterisks after the welcome message. Compile and run. Turn in a copy of the program and output.

Is PrintLines an example of a void or value returning function?

Is numLines being passed in or passed out?

Q3) Convert last weeks value returning functions, into void functions! Make the necessary changes to the function header, body and prototype:

Write a program that has a function named timesTen. The function should accept a double argument, and then multiply it by 10 and display the result to the screen.

Write a program that has a function called findAverage that takes as arguments 4 integers and calculates and displays the average of those numbers. Call the function in main, ask the user for the 4 integers and then pass them to the function.

The distance a vehicle travels can be calculated as follows:

Distance = Speed * Time

Write a function named calDistance that accepts a vehicles speed and time as arguments, and calculates and displays the distance the vehicle has traveled.

IF YOU LOOK AT MY LAST QUESTION BEFORE THIS, THE PROGRAMS ARE THERE WITH THE ANSWERS, JUST NEED IT TO BE CHANGED TO VOID FUNCTIONS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!