main ()
{
int menu, add, sub, mult, quit, num1, num2;
float dvd,Num1,Num2;// Here Num1 and Num2 is declared for Division operaion
printf ("=======================================\n");
printf ("Simple Calculator for Addition And Subtraction");
printf ("=======================================\n");
printf ("1.Add\n");
printf ("2.Sub\n");
printf ("3.Multiplication\n");
printf ("4.Division\n");
printf ("5.Quit\n");
printf ("Please Select what do you want?\n");
scanf ("%d", &menu);
switch (menu)
{
case 1:
printf ("Enter Two Numbers:\n");
scanf ("%d %d", &num1, &num2);
add = num1 + num2;
printf ("Addition =%d", add);
break;
case 2:
printf ("Enter Two Numbers:\n");
scanf ("%d %d", &num1, &num2);
sub = num1 - num2;
printf ("Subtraction =%d\n", sub);
break;
case 3:
printf ("Enter Two Numbers:\n");
scanf ("%d %d", &num1, &num2);
mult = num1 * num2;
printf ("Multiplication =%d\n", mult);
break;
case 4:
printf ("Enter Two Numbers:\n");
scanf ("%f %f", &Num1, &Num2);
dvd = Num1 / Num2;
printf ("Division =%.2f", dvd);
break;
case 5:
printf ("Program terminated!");
break;
default:
printf ("Wrong Input!");}
return 0;
}
No comments: