c语言实现简易计算器

Contributor:Starslayerx Type:代码 Date time:2020-02-23 15:16:42 Favorite:9 Score:0
返回上页 Report
请选择举报理由:




Collection Modify the typo
#include<stdio.h>
int main()
{
double number1=0.0;
double number2=0.0;
char operation=0;
printf("\nEnter the calculation\n");
scanf("%lf%c%lf",&number1,&operation,&number2);
switch(operation)
{
case '+':
printf("=%lf\n",number1+number2);
break;
case '-':
printf("=%lf\n",number1-number2);
break;
case '*':
printf("=%lf\n",number1*number2);
break;
case '/':
if(number2==0)
printf("\n\n\aDavision by zero error!\n");
else
printf("=%lf\n",number1/number2);
break;
case '%':
if((long)number2==0)
printf("\n\n\aDavision by zero error!\n");
else
printf("=%ld\n",(long)number1%(long)number2);
break;
default:
printf("\n\n\aDavision by zero error!\n");
break;
}
return 0;
}
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:
Difficulty:
quality:
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!

This paper typing ranking TOP20

用户更多文章推荐