猿问

向大佬提问,为什么我输a=1.1,b=1.1,结果s却是一堆懵逼的数字?

#include<math.h>

double area(double a,double b)

{double s=a*b;

return s;}

#include<stdio.h>

main(){

double a, b ,s;

printf("how much is your long");

scanf("%f",&a);

printf("how much is your wide");

scanf("%f",&b);

s=area(a,b);

printf("%f",s);

}



依木兰
浏览 757回答 3
3回答

___C___

double要用%lf格式,float才是%f格式。例如要修改为scanf("%lf",&a);感谢采纳
随时随地看视频慕课网APP
我要回答