/* C Program to simulate a calculator*/ ByAmit raj purohit
http://codevidyalay.blogspot.com
#include<stdio.h>
int main()
{
int a,b,c;char op;
printf("Enter an operator:");
scanf("%c",&op);
printf("Enter 2 values:");
scanf("%d%d",&a,&b);
switch(op)
{
case '+': c=a+b; break;
case '-': c=a-b; break;
case '*': c=a*b; break;
case '/': c=a/b; break;
case '%': c=a%b; break;
default :printf("Invalid choice"); return 0;
}
printf("Result is %d",c);
return 0;
}
INPUT/OUTPUT:
Enter an operator:*
Enter 2 values:8 9
Result is 72