...中如何用代码设计一个简单计算器,实瑞两个浮点数的加减乘除,界面如 ...

发布网友 发布时间:2024-10-24 02:17

我来回答

1个回答

热心网友 时间:2024-10-27 12:33

# include<stdio.h>
void main()
{
double first_number,second_number,value;
char Operator;
printf("please enter the number:\n");
scanf("%lf%c%lf",&first_number,&Operator,&second_number);
switch(Operator)
{
case '+': printf("value=%lf",first_number+second_number );break;
case '-': printf("value=%lf",first_number-second_number );break;
case '*': printf("value=%lf",first_number*second_number );break;
case '/': {if(second_number==0) printf("wrong number\n");
else printf("value=%lf",first_number/second_number);}
}

}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com