• Home
  • Blog
  • In C only 7.31 (Calculator Using Function Pointers) Using the techniques you learned in Fig….

In C only 7.31 (Calculator Using Function Pointers) Using the techniques you learned in Fig….

0 comments

In C only

7.31 (Calculator Using Function Pointers)
Using the techniques you learned in Fig. 7.28, create a text-based, menu-driven program that
allows the user to choose whether to add, subtract, multiply or divide two numbers. The
program should then input two double values from the user, perform the appropriate
calculation and display the result. Use an array of function pointers in which each pointer
represents a function that returns void and receives two double parameters. The corresponding
functions should each display messages indicating which calculation was performed, the values
of the parameters and the result of the calculation. In both cases, display the value to 2
digits of precision.
Note: do not accept invalid menu selections, print an error message and ask the user to try
again. Furthermore, if the user chooses division but enters 0 as the divisor, do not accept the
entry, print an error message and ask the user to enter another number instead.

===·Calculator·Menu·===?
?
Please·select·from·the·options·below:?
?
(0)·Add·a·number·to·another.?
(1)·Subtract·a·number·from·another.?
(2)·Multiply·a·number·to·another.?
(3)·Divide·a·number·by·another.?
?
Enter·your·selection:-1?
·Invalid·selection!?
Enter·your·selection:3?
·Enter·a·number:25.00?
·Enter·another·number:0.00?
·Error:·attempting·to·divide·by·zero!?
Enter·another·number:0.05?
·Dividing·25.00·by·0.05...?
The·result·is:·500.00?

 Jun 26 2022| 08:17 PM |

SOLUTION.PDF

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}