#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);
}
double 类型使用%f格式会导致输入值错误,换成%lf就可以了。
#include<stdio.h>
#include<math.h>
double area(double a,double b){
double s=a*b;
return s;
}
int main(){
double a, b ,s;
printf("how much is your long");
scanf("%lf",&a);
printf("how much is your wide");
scanf("%lf",&b);
s=area(a,b);
printf("%lf",s);
return 0;
}