C++ problem. Create a library with a following function, all of which have three
ID: 3797142 • Letter: C
Question
C++ problem. Create a library with a following function, all of which have three double input A, B, C Create a library with the following functions, all of which have three "double" inputs A, B, and C: -sum: returns the sum of A, B, and C avg: returns the average of A, B, and C max: returns the maximum of A, B, and C min: returns the minimum of A, B, and C Next, create a program that makes use of your library. Ask the user to input three values, call each function in the library, and output each result.Explanation / Answer
#include <iostream>
using namespace std;
double addition (double a, double b,double c)
{
double r;
r=a+b+c;
return r;
}
double avgerage (double a, double b,double c)
{
double r;
r=(a+b+c)/3;
return r;
}
double minimum (double a, double b,double c)
{
double r;
if(a<b && a<c)
r=a;
else if(b<c)
r=b;
else
r=c;
return r;
}
double maximum (double a, double b,double c)
{
double r;
if(a>b && a>c)
r=a;
else if(b>c)
r=b;
else
r=c;
return r;
}
int main ()
{
double z,x,y,w,a,b,c;
cin>>a;
cin>>b;
cin>>c;
z=addition(a,b,c);
x=avgerage(a,b,c);
y=minimum(a,b,c);
w=maximum(a,b,c);
cout<< "The sum is " << z<<endl;
cout<< "The avg is " << x<<endl;
cout<< "The min is " << y<<endl;
cout<< "The max is " << w<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.