Write your question here.
I am struggling with my code, it abends when it is trying to read the two numbers as input. It appears to loop and then gives me an option BREAK. Here are the guidelines:
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.
Any help would be very much appreciated!
[code]
Put the code you need help with here.
include <stdio.h>
int main()
{
void addition(double number1, double number2); /* create the functions */
void subtraction(double number1, double number2);
void division(double number1, double number2);
void multiplication(double number1, double number2);
int inputfunc=1;
double inputnum1=0;
double inputnum2=0;
while (inputfunc >= 1 && inputfunc <= 4) /* If function to be performed are those below then continue performing loop */
{
printf("Press 1 to add two numbers.\n");
printf("Press 2 to subtract two numbers.\n");
printf("Press 3 to multiply two numbers.\n");
printf("Press 4 to divide two numbers.\n");
printf("Press 5 to exit.\n");
printf("Enter your choice\n");
scanf_s("%d",&inputfunc);
if( inputfunc == 5) /* Exit program if requested via 5 function */
return(0);
printf("Enter both numbers with a space in between.");
scanf_s("%lf %lf", inputnum1, inputnum2);