Calculator Program help

I am having some issues and can't figure out what my errors are. I need to do this in C. Thanks.

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 choice;
double number1=0;
double number2=0;

while (choice >= 1 && choice <= 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",&choice);

if( choice == 5) /* Exit program if requested via 5 function */
return(0);

printf("Enter both numbers with a space in between.");
scanf_s("%lf %lf", number1, number2);

void(*func[4])(double, double)={&addition, &subtraction, &division, &multiplication};
(*func[choice-1])(number1, number2);
return(0);
}
}
void addition(double number1, double number2)
{
double answer;
answer=number1+number2;
printf("Addition of the two numbers = %lf + %lf = %lf\n", number1, number2, answer);
return;
}

void subtraction(double number1, double number2)
{
double answer;
answer=number1-number2;
printf("By subtracting the two numbers results are %lf - %lf = %lf\n", number1, number2, answer);
return;
}

void multiplication(double number1, double number2)

{
double answer;
answer=number1*number2;
printf("By multiplying the two numbers results are %lf * %lf = %lf\n", number1, number2, answer);
return;
}

void division(double number1, double number2)

{
double answer;
answer=number1/number2;
printf("By dividing the two numbers results are %lf / %lf = %lf\n", number1, number2, answer);
return;
}
/code
What specific problems are you having?
Topic archived. No new replies allowed.