Question
Convert these value returning functions into void functions. Make the necessary changes to the function header, body and prototype: 1. #include using namespace std; double
Convert these value returning functions into void functions. Make the necessary changes to the function header, body and prototype:
1.
#include
using namespace std;
double timesTen (double value);
int main()
{
double value = timesTen (10);
cout << "Ten times the value is: " << value << endl;
return 0;
}
double timesTen(double num)
{
return num * 10;
}
2.
#include
using namespace std;
double findAverage(int num1, int num2, int num3, int num4);
int main()
{
int num1, num2, num3, num4;
cout << "Please enter your number (1): ";
cin >> num1;
cout << "Please enter your number (2): ";
cin >> num2;
cout << "Please enter your number (3): ";
cin >> num3;
cout << "Please enter your number (4): ";
cin >> num4;
double value = findAverage(num1, num2, num3, num4);
cout << "Average value is: " << value << endl;
return 0;
}
double findAverage(int num1, int num2, int num3, int num4)
{
return ((num1 + num2 + num3 + num4) / 4);
}
3.
#include
using namespace std;
double calDistance (int speed, int time);
int main()
{
double value = calDistance (40, 60);
cout << "Distance value is: " << value << endl;
return 0;
}
double calDistance (int speed, int time)
{
return speed * time;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started