Question

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

program in c++  

Homework Answers

Answer #1

#include
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<<"\nSummation = "<    cout<<"\nMean= "<    cout<<"\nMedian = "<    cout<<"\nFactorial = "< 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\n ", 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 );
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a C++ program to compute the value of x * (x + 1) + y...
Write a C++ program to compute the value of x * (x + 1) + y * y + z * (z - 1) where x, y, and z are 3 floating point numbers entered by the user. Requirements: • You should have a function get3numbers() that asks the user to enter 3 numbers. • You should have a function computeExp() that computes the value of the expression. • Your main function should call the above 2 functions and get...
c++ Write a program that calls a function calculateSum to calculate the sum from -1 to...
c++ Write a program that calls a function calculateSum to calculate the sum from -1 to N. The function calculateSum has one parameter N of type integer and returns an integer which represents the sum from -1 to N, inclusive. Write another function calculateAverage that calculates an average. This function will have two parameters: the sum and the number of items. It returns the average (of type float). The main function should be responsible for all inputs and outputs. Your...
A program is already given to you.  There are five problems in this skeleton version of the...
A program is already given to you.  There are five problems in this skeleton version of the program, each is 10 points. All you got to do is complete the missing code in each function. What the function does is clearly stated in the name of the function.   // ASSIGNMENT ON FUNCTIONS #include <stdio.h> // Problem 1: Compile with gcc func_assignment.c -Wall // There are some warnings because there is a mismatch between // data type passed and defined. // Find...
Write spim program and execute it on mars. Your program reads two integer values x and...
Write spim program and execute it on mars. Your program reads two integer values x and y. Write a function called sum that gets x and y passed as parameters and return the sum of odd values between x and y inclusive. In addition write another function called even that gets x and y as parameters and returns the count of all even numbers between x and y inclusive. Also in main print the quotient and remainder of diving y...
Write a C++ program which consists of several functions besides the main() function. 1)   The main()...
Write a C++ program which consists of several functions besides the main() function. 1)   The main() function, which shall ask for input from the user (ProcessCommand() does this) to compute the following: SumProductDifference and Power. There should be a well designed user interface. 2)   A void function called SumProductDifference(int, int, int&, int&, int&), that computes the sum, product, and difference of it two input arguments, and passes the sum, product, and difference by-reference. 3)   A value-returning function called Power(int a,...
Three numbers x, y, and z that sum to 99 and also have their squares sum...
Three numbers x, y, and z that sum to 99 and also have their squares sum to 99. By Lagrange method, find x, y, and z so that their product is a minimum.
Find the maximum and minimum values of the function f(x,y,z)=x+2y subject to the constraints y^2+z^2=100 and...
Find the maximum and minimum values of the function f(x,y,z)=x+2y subject to the constraints y^2+z^2=100 and x+y+z=5. I have: The maximum value is ____, occurring at (___, 5sqrt2, -5sqrt2). The minimum value is ____, occurring at (___, -5sqrt2, 5sqrt2). The x-value of both of these is NOT 1. The maximum and minimum are NOT 1+10sqrt2 and 1-10sqrt2, or my homework program is wrong.
IV.Translate the following C code fragment to ARM assembly instructions. Assume t, x, y, and z...
IV.Translate the following C code fragment to ARM assembly instructions. Assume t, x, y, and z are stored in registers r0, r1, r2, and r3. unsigned int x, y, z, t; do { x = x + 1; z = t + (z << 1); y = y - x; } while (y != x); V. What does the following sequence of instructions do? Why? RSB r2, r3, r3, LSL #4 RSB r2, r2, r2, LSL #3 VI. Write a...
Write a C++ program to do the following: Declare and assign values to int variables x,...
Write a C++ program to do the following: Declare and assign values to int variables x, y Declare an int variable z; and store the sum of x and y in it Declare a pointer called pz and point it in the heap direction (using new) Store the z value in the heap location using the pz pointer Print the content of the pz pointer Print the pointer (the address)
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...