Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ 10. Design a function calculate() that takes two type double values and a pointer to a function that takes two double arguments and returns
c++
10. Design a function calculate() that takes two type double values and a pointer to a function that takes two double arguments and returns a double. The calculate() function should also be type double, and it should return the value that the pointed-to function calculates, using the double arguments to calculate(). For example, suppose you have this definition for the add() function: double add (double x, double y return x + y: Then, the function call in the following would cause calculate() to pass the val ues 2.5 and 10.4 to the add function and then return the add return value (12.9); double calculate 12.5, 10.4. add Use these functions and at least one additional function in the add moldina program. The program should use a loop that allows the user to enter pairs of num bers. For each pair, use calculated to invoke add () and at least one other fund tion. If you are feeling adventurous, try creating an array of pointers to adastyle functions and use a loop to successively apply calculated to a series of functions by using these pointers. Hint: Here's how to declare such an array of three pointers double double double You can initialize such an array by using the usual array mitalization syntax and function cames as addresses O is hpStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started