Question

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 the job done. • You must determine the parameters and returning values of all those functions.

Homework Answers

Answer #1
#include<iostream>
using namespace std;

void get3numbers(float& x, float& y, float& z){
   cout<<"Enter value for x: ";
   cin>>x;
   cout<<"Enter value for y: ";
   cin>>y;
   cout<<"Enter value for z: ";
   cin>>z;
}

float computeExp(float x, float y, float z){
   return x * (x + 1) + y * y + z * (z - 1);
}

int main(){
   float x, y, z, res;
   get3numbers(x,y,z);
   res = computeExp(x,y,z);
   
   cout<<"Result = "<<res<<endl;
   
   return 0;
}
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
A) write a program the computes nx and store the result into y You can use...
A) write a program the computes nx and store the result into y You can use y = Math.pow( Mantissa, exponent) Requirements: Besides main() your program must have one method with two parameters, one double and one int n and x are positive numbers read from the keyboard if the user makes an entry that does not meet this criteria, the user must be given to opportunity retry the entry the user must be able to quit prior to entering...
float sum( float x, float y, float z ) ​program in c++
Here are the function prototypes for your homeworkWrite 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 themselvesfloat sum( float x, float y, float z ); // returns the sum of three floatsfloat mean( float...
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,...
Write a C program Design a program that uses an array to store 10 randomly generated...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
in C++ Write a program. The program should prompt the user for the number of shares...
in C++ Write a program. The program should prompt the user for the number of shares purchased, purchase price per share, the commission for the purchase, sale commission paid, and the price the shares were sold at. The program should validate each of these values to ensure they are acceptable (none can be less than zero) and should then pass them to a function called numberfunction.The function should use the following formula to determine the profit: Profit = ((number of...
Write a complete assembly language program that computes in EAX the value of the expression x...
Write a complete assembly language program that computes in EAX the value of the expression x − 2y + 4z for doublewords in memory at x, y, and z. Choose the current month (1–12), day (1–31), and year (all four digits) for the values of x, y, and z.
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
ALL IN PYTHON PLEASE Problem 4 Write a program to compute the area of a circle...
ALL IN PYTHON PLEASE Problem 4 Write a program to compute the area of a circle some 'n' times. You must accept n and r from the user. Area is calculated using (22/7.0)*r*r - where r is the radius. Implement using value-returning functions. Hint: create a function to calculate area taking r as a parameter. In the main() function, ask for n and create a loop where you input r and invoke the area function n times. Rubric: Correct use...
Write the following functions and provide a program to test them (main and all functions in...
Write the following functions and provide a program to test them (main and all functions in one .py). 6 pts def allTheSame(x, y, z) (returning true if the arguments are all the same) def allDifferent(x, y, z) (returning true if the arguments are all different) def sorted(x, y, z) (returning true if the arguments are sorted, smallest one first keep it simple, python
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT