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
|
#include <stdio.h>
int main()
{
int a,b,c;
char x;
printf("What would you like to do\n");
printf("1. Addition\n");
printf("2. Multiplication\n");
printf("3. Division\n");
printf("4. Subtraction\n");
for(;;)
{
printf("Enter your choice- 1,2,3 or 4\n");
x=getchar();
if(x=='1')
{
printf("Enter two numbers\n");
scanf("%d""%d",&a,&b);
c=a+b;
printf("The answer is %d \n",c);
}
else if(x=='2')
{
printf("Enter two numbers\n");
scanf("%d""%d",&a,&b);
c=a*b;
printf("The answer is %d \n",c);
}
else if(x=='3')
{
printf("Enter two numbers\n");
scanf("%d""%d",&a,&b);
c=a/b;
printf("The answer is %d \n",c);
}
else if(x=='4')
{
printf("Enter two numbers\n");
scanf("%d""%d",&a,&b);
c=a-b;
printf("The answer is %d \n",c);
}
else
{
printf("Not a good choice\n");
}
}
return(0);
}
|