1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main()
{
float numberA;
float numberB;
char choice;
printf("Please choose one of the following options:");
printf("\n\t1.Addition");
printf("\n\t2.Subtraction");
printf("\n\t3.Multiplication");
printf("\n\t4.Division\n\n\t");
printf("I choose: ");
choice=getchar();
switch(choice)
{
case'1':
printf("\nEnter your first number: ");
scanf("%f", &numberA);
printf("\nEnter your second number: ");
scanf("%f", &numberB);
printf("\n%f + %f = %.3f\n",numberA, numberB, numberA+numberB);
case'2':
printf("\nEnter your first number: ");
scanf("%f", &numberA);
printf("\nEnter your second number: ");
scanf("%f", &numberB);
printf("\n%f - %f = %.3f\n", numberA, numberB, numberA-numberB);
case'3':
printf("\nEnter your first number: ");
scanf("%f", &numberA);
printf("\nEnter your second number: ");
scanf("%f", &numberB);
printf("\n%f * %f = %.3f\n", numberA, numberB, numberA*numberB);
case'4':
printf("\nEnter your first number: ");
scanf("%f", &numberA);
printf("\nEnter your second number: ");
scanf("%f", &numberB);
printf("\n%f / %f = %.3f\n", numberA, numberB, numberA/numberB);
}
system("pause");
}
|