Source Code
#include<stdio.h>
int
main ()
{
int menu, add, sub, quit, num1, num2;
printf ("======================================================\n");
printf ("Simple Calculator for Addition And Subtraction");
printf ("======================================================\n");
printf ("1.Add\n");
printf ("2.Sub\n");
printf ("3.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("Program terminated!");
break;
default:
printf ("Wrong Input!");
}
return 0;
}
No comments: