#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define EPS 1e-7
int main()
{
float data1,data2;
char op;
printf("please enter an expression:");
scanf("%f %c%f",&data1,&op,&data2);
switch(op)
{
case '+':
printf("%f+%f = %f",data1,data2,data1+data2);
break;
case '-':
printf("%f-%f = %f",data1,data2,data1-data2);
break;
case 'x':
printf("%fx%f = %f",data1,data2,data1*data2);
break;
case '/':
if(fabs(data2) <= EPS )
printf("division by zero!\n");
else
printf("%f/%f = %f",data1,data2,data1/data2);
break;
default:
printf("invalid operator!\n");
}
return 0;
}