#include<stdio.h>main(){ double a,b,sum; printf("please press two numbers:\n"); scanf("%f%f",&a,&b); sum=a+b; printf("The sum of %f + %f is %f\n",a,b,sum); return 0;}当我执行时,输出情况为:但是我将double改为float后 输出结果正确 为啥咧。
3 回答
慕娘9325324
TA贡献1783条经验 获得超4个赞
double类型的话
scanf("%f%f",&a,&b); 改为 scanf("%lf%lf",&a,&b);
printf("The sum of %f + %f is %f\n",a,b,sum); 改为printf("The sum of %lf + %lf is %lf\n",a,b,sum);
- 3 回答
- 0 关注
- 259 浏览
添加回答
举报
0/150
提交
取消