this is now rewritten. My problem though is that it wants to modulate everything after I press a key. So for example, I will press A to add, it will do the add function, then it will ask me for the numbers to modulate.
Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
float A[3], S[2], M[3], D[2], O[2];
float add, subtract, multiply, divide, modulate;
char E;
char choice;
printf("Please type in one of the following letters:");
printf("\nA to Add three numbers: ");
printf("\nS to Subtract two numbers: ");
printf("\nM to Multiply three number: ");
printf("\nD to Divide two number: ");
printf("\nO to Modulate two number: ");
printf("\nE to Exit program: ");
printf("\n>");
scanf("%c", &choice);
if (choice == 'A' || choice == 'a')
{
printf("\nPlease type in the first number: ");
scanf("%f", &A[0]);
printf("\nPlease type in the second number: ");
scanf("%f", &A[1]);
printf("\nPlease type in the third number: ");
scanf("%f", &A[2]);
add=A[0]+A[1]+A[2];
printf("\n%.2f plus %.2f plus %.2f is: %.2f", A[0], A[1], A[2], add);
}
if (opselect == 'S' || opselect == 's')
{
printf("\nPlease type in the first number: ");
scanf("%f", &S[0]);
printf("\nPlease type in the second number: ");
scanf("%f", &S[1]);
subtract=S[0]-S[1];
printf("\n%.2f minus %.2f minus %.2f is: %.2f", S[0], S[1], subtract);
}
if (choice == 'M' || choice == 'm')
{
printf("\nPlease type in the first number: ");
scanf("%f", &M[0]);
printf("\nPlease type in the second number: ");
scanf("%f", &M[1]);
printf("\nPlease type in the third number: ");
scanf("%f", &M[2]);
multiply=M[0]*M[1]*M[2];
printf("\n%.2f times %.2f times %.2f is: %.2f", M[0],M[1], M[2], multiply);
}
if (choice == 'D' || choice == 'd')
{
printf("\nPlease type in the first number: ");
scanf("%f", &D[0]);
printf("\nPlease type in the second number: ");
scanf("%f", &D[1]);
divide=D[0]/D[1];
printf("\n%.2f divided by %.2f is: %.2f", D[0], D[1], divide);
}
if (choice == 'O' || choice == 'o');
{
printf("\nPlease type in the first number: ");
scanf("%f", &O[0]);
printf("\nPlease type in the second number: ");
scanf("%f", &O[1]);
modulate = fmod(O[0],O[1]);
printf("\nThe modulus of %.2f and %.2f is remainder: %.2f", O[0], O[1], modulate);
}
if (choice == 'E' || choice == 'e')
{
printf("\nThank You and Goodbye!: ");
scanf("%c", &E);
}
return 0;
}
<<continued here>>