C语言实现四则运算

#include<stdio.h>

 int main(void)
 {
double value1,value2;
char  op;
 printf("Type in an expression:");

scanf("%lf%c%lf",&value1&op&value2);
if(op=='+')
printf("=%.2f\n",value1+value2);

else if(op=='-')

printf("=%.2f\n",value1-value2);

else if(op=='*')
printf("=%.2f\n",value1*value2);
else if(op=='/')
printf("=%.2f\n",value1/value2);
else
printf("Unknown opterator\n");
return 0;

 

posted on 2016-03-12 16:13  张宏伟。。  阅读(1277)  评论(1编辑  收藏  举报