Question: Convert the value returning functions below into void functions. Make the necessary changes to the function header, body and prototype: 1) #include using namespace std;

Convert the value returning functions below into void functions. Make the necessary changes to the function header, body and prototype:

1)

#include

using namespace std;

//declare the function

double timesTen(double num);

int main ()

{

//calling a function to get ten times the value of the argument.

double value = timesTen(10.50);

cout

return 0;

}

double timesTen(double num)

{

return num * 10;

}

Output:

Convert the value returning functions below into void functions. Make the necessary

2)

#include

using namespace std;

//declare the function

double findAverage(int num1, int num2, int num3, int num4);

int main ()

{

int num1,num2,num3,num4;

cout

cin >> num1;

cout

cin >> num2;

cout

cin >> num3;

cout

cin >> num4;

//calling a function to get average of four numbers.

double value = findAverage(num1,num2,num3,num4);

cout

return 0;

}

double findAverage(int num1, int num2, int num3, int num4)

{

return ((num1+num2+num3+num4)/4);

}

Output:

changes to the function header, body and prototype: 1) #include using namespace

3)

#include

using namespace std;

//declare the function

double calDistance(int speed, int time);

int main ()

{

//calling a function to get distance.

double value = calDistance(30,45);

cout

return 0;

}

double calDistance(int speed, int time)

{

return speed * time;

}

Output:

std; //declare the function double timesTen(double num); int main () { //calling

4)

#include

using namespace std;

//declare the function

double fahrenheit(double centigrade);

int main ()

{

/* Calling it in a loop that displays a table of the Centigrade temperature 0 through 20

and their Fahrenheit equivalents, i.e. call the function inside the loop! */

for(int i=0; i

{

double value = fahrenheit(i);

cout Fahrenheit: "

}

return 0;

}

double fahrenheit(double centigrade)

{

return ((centigrade * 9.0) / 5.0 + 32);

}

Output:

a function to get ten times the value of the argument. double

Ten times the value is: 100 Process exited after 0.07739 seconds with return value 0 Press any key to continue

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!