急,跪求答案,有关C语言,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:35:50
#include "stdio.h"
float area(float h,float w);
{
float s;
s=h*w;
return s;
}
main()
{
float h1,h2,w1,w2,s1,s2;
h1=10.5; w1=20.5;
h2=1.5h1; w2=1.5*w1;
s1=area(h1,w1);
s2=area(h2,w2);
printf(" area=%6.2f", s1+s2);
}
该程序运行出错,怎么改?
error C2449: found '{' at file scope (missing function header?)
error C2059: syntax error : '}'
error C2059: syntax error : 'bad suffix on number'
执行 cl.exe 时出错.

粗心了

float area(float h,float w)//////将原先的分号去掉
{
float s;
s=h*w;
return s;
}
main()
{
float h1,h2,w1,w2,s1,s2;
h1=10.5; w1=20.5;
h2=1.5*h1; w2=1.5*w1; /////将原先的h2=1.5h1改为h2=1.5*h1
s1=area(h1,w1);
s2=area(h2,w2);
printf(" area=%6.2f", s1+s2);
}