Question

Part 1: In your own words, define a function. Part 2: Code the following function in...

Part 1: In your own words, define a function.

Part 2: Code the following function in C++. The function is named potential. It receives three double type parameters (mass, gravity and height). It multiplies all three parameters to calculate potential energy which is returned as a double. Just paste the code for the potential function - no main function is required.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The code for the potential function is below

double potential (double mass, double gravity , double height)

{
double potential_energy = ( mass * gravity * height ) ;
return  potential_energy ;

}

Add a comment
Know the answer?
Add Answer to:
Part 1: In your own words, define a function. Part 2: Code the following function in...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 25. (15 pes) Write the C++ code for a function that receives three double numbers. The function should calculate the average of the three numbers and them returm the result. Name the function con...

    25. (15 pes) Write the C++ code for a function that receives three double numbers. The function should calculate the average of the three numbers and them returm the result. Name the function conm Name the fornal parameters aumi, nu compAverage function. In addition, write a statement that invokes the compAverage f assigns its arguments: 14.50, 18.72, and S3.1 function and its return value to a double variable named answer. Use the following mumbers as the 26, (5 pts) Write...

  • 1. Write code for a function that receives two parameters (a,and b) by value and two...

    1. Write code for a function that receives two parameters (a,and b) by value and two more parameters (c and d) by reference. All parameters are double. The function works by assigning c to (a/b) and assigning d to (a*b). The function has no return value. From main, use scanf to get two numbers, then call the function, and then display both outcome values to the output in a printf statement. 2. After part 1 is completed, write code to...

  • #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort,...

    #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort, search // Define computeAvg here // Define findMax here // Define findMin here // Define selectionSort here ( copy from zyBooks 11.6.1 ) // Define binarySearch here int main(void) { // Declare variables FILE* inFile = NULL; // File pointer int singleNum; // Data value read from file int valuesRead; // Number of data values read in by fscanf int counter=0; // Counter of...

  • answer in c++ Using the table below, complete the C++ code to write the function prototype...

    answer in c++ Using the table below, complete the C++ code to write the function prototype statement, and the void function header. The void function should receive three double variables: the first two by value and the last one by reference. Name the formal parameters num1, num2 and answer. The function should divide the num1 variable by the num2 variable and then store the result in the answer variable. Name the function calcQuotient. Also write an appropriate function prototype for...

  • Using C++ 1) Write a function that receives the numerator and denominator of a fraction and...

    Using C++ 1) Write a function that receives the numerator and denominator of a fraction and returns its corresponding value as a double precision real number. The function also receives the number of digits that the value must be rounded to before returned. To test it, you must implement the algorithm provided below. Note: You must define the most appropriate type of function, the parameter list (using the most appropriate parameters), and the body of the function to be implemented....

  • 1- Write a program that creates a dictionary of the English words for all single digit...

    1- Write a program that creates a dictionary of the English words for all single digit numbers as follows: 1: 'one', 2: 'two', 3: 'three', etc. 2- Write a function called numConvert that receives the above dictionary and an integer number as parameters, and prints the English words for all the number's digits. For example, if the function receives 2311, it will print: two three one one 3- Test your program by adding a main function, which calls numConvert. 4-...

  • In words, define the term force; explain how mass can be used to define the force...

    In words, define the term force; explain how mass can be used to define the force unit Newton Name and draw all of the significant forces that act on any common object (such as an airplane in flight) Explain what is meant by the normal force, and be able to draw it and calculate it for common objects Explain in your own words all three of Newton's Laws of Motion Use Newton's Laws to explain how any object will behave...

  • C++ 1) Write a function named WordCount, which determines the number of words in a “C...

    C++ 1) Write a function named WordCount, which determines the number of words in a “C type” string. The function will have one parameter (the address of the string) and will return the number of words (words are separated by one or more spaces). (15 points) 2) Write a function named VowelConsonant which will have three parameters - all “C type” strings. The function will place all vowels (the characters a, e, i, o, u) from the first string into...

  • Please define all terms in your own words Superposition of States and Statistical Probability Potential Energy...

    Please define all terms in your own words Superposition of States and Statistical Probability Potential Energy and Gibbs Free energy The infinite square well The finite square well Tunneling Schrodinger's Equation Time-Dependent vs Time-Independent form o Normalization Continuity and Boundary Conditions Superposition of States and Statistical Probability Potential Energy and Gibbs Free energy The infinite square well The finite square well Tunneling Schrodinger's Equation Time-Dependent vs Time-Independent form o Normalization Continuity and Boundary Conditions

  • Code the following Program in C++ Define a class named Payment that contains a member variable...

    Code the following Program in C++ Define a class named Payment that contains a member variable of type float that stores the amount of the payment and appropriate accessor and mutator methods.    Also create a member function named paymentDetails that outputs an English sentence that describes the amount of the payment. Next define a class named CashPayment that is derived from Payment. This class should redefine the paymentDetails function to indicate that the payment is in cash. Include appropriate constructor(s)....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT