/*求解简单的五则运算表达式*/
#include<stdio.h> int main(void) { double num1,num2; char op; printf("Type in an expression:"); /*提示输入一个表达式*/
scanf("%lf%c%lf",&num1,&op,&num2); /*输入表达式*/
if(op=='+') /*判断运算符是否为’+‘*/
printf("=%.2f ",num1+num2); else if(op=='-') /*判断运算符是否为’-‘*/
printf("=%.2f ",num1-num2); else if(op=='*') /*判断运算符是否为’*‘*/
printf("=%.2f ",num1*num2); else if(op=='/') /*判断运算符是否为’/'*/
printf("=%.2f ",num1/num2); else printf("Unknown operator "); /*运算符输入错误*/ return 0; }