编写一个简易计算器程序,根据用户输入的运算符做两个数的加,减,乘或除运算

2024-11-16 21:33:20
推荐回答(1个)
回答1:

#include
main()
{double a,b;
double result:
char operator;

printf("Pleasr input two number:");
scanf("%f,%f"碧尺裤,&a,&b);
printf("please input the operator:");
scanf(%c",&operator);
if(opreator=='+'悔简)
printf("result=%d\n",a+b);
else if(opreator=='-')
printf("result=%d\n",a-b);
else if(opreator=='*')
printf("result=%d\n",a*b);
else if(opreator=='/')
printf("result=%d\n"困手,a/b);
else printf("Wrong!");

getch();

}