Q. WAP to use Arithmetic operators (Mini Calculator). 294
#include<stdio.h>
#include<conio.h>
void main()
{
char op;
int a, b, res;
clrscr();
printf("\nEnter 2 numbers: ");
scanf("%d%d",&a, &b);
printf("\nEnter operator (+, -, /, *): ");
fflush(stdin); //to clean the buffered value
scanf("%c",&op);
switch(op)
{
case '+':
res = a+b;
break;
case '-':
res = a-b;
break;
case '/':
res = a/b;
break;
case '*':
res = a*b;
break;
}
printf("Result = %d",res);
getch();
}
Enter 2 numbers: 10
20
Enter operator (+, -, /, *): +
Result = 30
20
Enter operator (+, -, /, *): +
Result = 30