i don't have a clue what is wrong here....
the program is supposed to add, subtract, multiply and divide two real numbers.
#include<stdio.h>
float add(float x, float y);
float subtract(float x, float y);
float multiply(float x, float y);
float divide(float x, float y);
int main (void)
{
int choice;
float x, y;
while(1)
{
printf("\nPress 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 the program.\n");
printf("\nEnter your choice:\n");
scanf("%d",&choice);
if(choice==5)
{
return 0;
}
if(choice >= 1 && choice <= 4)
{
printf("Please enter a real number:\n");
scanf("%f", &x);
printf("Please enter another real number:\n");
scanf("%f", &y);
if (choice==1)
{
printf("The sum of both values inputted: % f\n", add(x, y));
}
float add(float x, float y)
{
return x+y;
}
else if (choice==2)
{
printf("The difference of both values inputted: % f\n", subtract(x, y));
}
float subtract(float x, float y)
{
return x-y;
}
else if (choice==3)
{
printf("The difference of both values inputted: % f\n", multiply(x, y));
}
float multiply(float x, float y)
{
return x*y;
}
else if (choice==4)
{
printf("The difference of both values inputted: % f\n", divide(x, y));
scanf("%f",x/y)
}
float divide(float x, float y)
{
return x/y;
}
}
}