Homework 02162017 Here are the function prototypes for yo
// Homework -- 02/16/2017 // Here are the function prototypes for your homework // Write out the actual functions themselves // Also create a main function that demonstrates that all four functions work // The user should be able to provide four values to your program (three floats and an int) // Your program should then use your four new functions and also display the results to the user // NONE of these functions should print values themselves
float sum( float x, float y, float z ); // returns the sum of three floats
float mean( float x, float y, float z ); // returns the mean (average) of three floats
float median( float x, float y, float z ); // returns the middle value of three floats
unsigned long long factorial( unsigned int x ); // returns the factorial of the integer x
i neeed to make a program in c++ please help me
Solution
#include <iostream>
using namespace std;
float sum( float x, float y, float z ); // returns the sum of three floats
float mean( float x, float y, float z ); // returns the mean (average) of three floats
float median( float x, float y, float z ); // returns the middle value of three floats
unsigned long long factorial( unsigned int x ); // returns the factorial of the integer x
int main()
{
float a,b,c;
unsigned int d;
cout<<\"Enter any three float numbers: \";
cin>>a>>b>>c;
cout<<\"Enter any integer number\";
cin>>d;
cout<<\"\ Summation = \"<<sum(a, b, c);
cout<<\"\ Mean= \"<<mean(a, b, c);
cout<<\"\ Median = \"<<median(a, b, c);
cout<<\"\ Factorial = \"<<factorial(d);
return 0;
}
float sum( float x, float y, float z)
{
float p;
p=x+y+z;
return(p);
}
float mean( float x, float y, float z)
{
float p;
p=(x+y+z)/3;
return(p);
}
float median( float x, float y, float z)
{
float second_max;
if ( x < y )
{
if ( y < z ) second_max = y;
else second_max = ( x < z ? z : x );
}
else
{
if ( x < z ) second_max = x;
else second_max = ( y < z ? z : y );
}
// printf( \"second maximum value is %d\ \", second_max );
return (second_max);
}
unsigned long long factorial( unsigned int x )
{
int c;
long result = 1;
for( c = 1 ; c <= x ; c++ )
result = result*c;
return ( result );
}

