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
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...
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...
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.
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...
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.
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)
Question 5: Recommend / Explain a C++ program which uses an array of 20 integers whose...
Question 5: Recommend / Explain a C++ program which uses an array of 20 integers whose input is taken by user, the array is passed to a functions named i.e. smallest(int A[20) and largest(int B[20]) to determine minimum and maximum values respectively. Also create a function named modify(int *p) which modifies the value at the index given by user.
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...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF...
WRITE C++ PROGRAM FOR 1,2,3,4 PARTS of question, DO ADD COOMENTS AND DISPLAY THE OUTPUT OF A RUNNING COMPILER QUESTION: 1) Fibonacci sequence is a sequence in which every number after the first two is the sum of the two preceding ones. Write a C++ program that takes a number n from user and populate an array with first n Fibonacci numbers. For example: For n=10 Fibonacci Numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 2): Write...
How would I write the following program in C programming language? Function header: int sumsort(int *a,...
How would I write the following program in C programming language? Function header: int sumsort(int *a, int *b, int *c) This function should arrange the 3 values in the memory locations pointed to by a, b, and c in ascending order and also return the sum of the contents of the memory locations a, b, and c.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT