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

来源:百度知道 编辑:UC知道 时间:2024/07/07 20:24:00
小弟是新手,这个问题似乎很幼稚..所以最好能再帮我解释一下额..在这里谢谢了。

#include<stdio.h>
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();

}