You are on page 1of 2

#include <stdio.

h>
void addNumbers();
void subtractNumbers();
void multiplyNumbers();
void divideNumbers();
void modNumbers();

void main (void)


{
char operation;
printf("Enter an operation: ");
scanf("%c", &operation);
switch(operation)
{
case 'A' : addNumbers(); break;
case 'S' : subtractNumbers(); break;
case 'M' : multiplyNumbers(); break;
case 'D' : divideNumbers(); break;
case 'L' : modNumbers(); break;
default : printf("Invalid operation, please try again\n"); break;
}
}

void addNumbers (void)


{
float sum, num1, num2;
printf("Enter two numbers (or -100 to exit): \n");
scanf("%f %f", &num1, &num2);
sum = num1 + num2;
printf("Sum = %.2f\n\n", sum);
}

void subtractNumbers (void)


{
float subtraction, num1, num2;
printf("Enter two numbers (or -100 to exit): \n");
scanf("%f %f", &num1, &num2);
subtraction = num1 - num2;
printf("Subtraction = %.2f\n\n", subtraction);
}

void multiplyNumbers (void)


{
float multiplication, num1, num2;
printf("Enter two numbers (or -100 to exit): \n");
scanf("%f %f", &num1, &num2);
multiplication = num1 * num2;
printf("Multiplication = %.2f\n\n", multiplication);
}

void divideNumbers (void)


{
float division, num1, num2;
printf("Enter two numbers (or -100 to exit): \n");
scanf("%f %f", &num1, &num2);
division = num1 / num2;
printf("Division = %.2f\n\n", division);
}
void modNumbers (void)
{ float modulus, num1, num2;
printf("Enter two numbers (or -100 to exit): \n");
scanf("%f %f", &num1, &num2);
modulus = num1 + num2;
printf("Modulus = %.2f\n\n", modulus);
}

You might also like