#include<stdio.h>
int main() {
char op;
double first,second;
printf("Enter an operator (+,-,*,/): ");
scanf("%c",&op);
printf("Enter two operands: ");
scanf("%lf %lf",&first,&second);
switch (op){
case'+':
printf("%1lf + %1lf=%1lf",first,second,first+second);
break;
case'-':
printf("%1lf - %1lf=%1lf",first,second,first-second);
break;
case'*':
printf("%1lf * %1lf=%1lf",first,second,first*second);
break;
case'/':
printf("%1lf / %11lf=%1lf",first,second,first/second);
break;
//operator does not match any case constant
default:
printf("Error!operator is not correct");
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: