编写一个简易计算器程序,根据用户输入的运算符做两个数的加,减,乘或除运算
1个回答
展开全部
#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();
}
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();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询