Respuesta :
Answer:
Following are the program in the C++ Programming Language.
#include<iostream> //header file
#include<iomanip> //header file
using namespace std;//using namespace
//set method for sum
double findSum(double x, double y, double z)
{
double s = x+y+z;
return s;
}
//set method for Average
double findAverage(double s, int a)
{
double avg = s/a;
return avg;
}
//set method for smallest number
double findSmallest(double x, double y, double z)
{
double mn;
if(x<y && x<z)
mn = x;
else if(y<x && y<z)
mn = y;
else if(z<x && z<y)
mn = z;
return mn;
}
//set the main function
int main()
{
cout<<fixed<<setprecision(2)<<endl;
//set double type variables
double xx, yy, zz, t, avg, mn;
//get input from the user
cout<<"Enter first value: ";
cin>>xx;
cout<<"Enter second value: ";
cin>>yy;
cout<<"Enter third value: ";
cin>>zz;
//calling of functions and store their values
t = findSum(xx, yy, zz);
avg = findAverage(t, 3);
mn = findSmallest(xx, yy, zz);
//print the output
cout<<"\n";
cout<<"Results: "<<endl;
cout<<"First number "<<xx<<endl;
cout<<"Second number "<<yy<<endl;
cout<<"Third number "<<zz<<endl;
cout<<"Total "<<t<<endl;
cout<<"Average "<<avg<<endl;
cout<<"Smallest "<<mn<<endl;
return 0;
}
Output:
Enter first value: 17.23
Enter second value: 3.98
Enter third value: 22.32
Results:
First number 17.23
Second number 3.98
Third number 22.32
Total 43.53
Average 14.51
Smallest 3.98
Explanation:
Here, we define the double data type function " findSum()" in which we pass three double type arguments "x", "y", "z" in its parentheses.
- inside it, we set the double type variable 's' in which we store the sum of variable x, y, z and return the variable s.
Then, we define the function "findAverage()" in which we pass two arguments double type s and integer type a.
- inside it, we set the double type variable avg in which web store the divide of s and a then return avg
Then we set the function "findSmallest()" in which we pass three double type arguments "x", "y", "z" in its parentheses.
- inside it, we set the double type variable "mn" which store the value of the smallest number among them.
Finally, we define the main function in which se call and pass the function and the value in its parameter then, we print the result.