想知道我这段简单的程序哪错了,怎样看下面的错误解释

来源:百度知道 编辑:UC知道 时间:2024/05/06 04:09:42
include <stdio.h>
main()
{
float c,f;
printf("请输入一个华氏温度:\n");
scanf("%f,&f");
c=(5.0/9.0)*(f-32);
printf("摄氏温度为:%5.2f\n",c);
}

错误解释
--------------------Configuration: 38 - Win32 Debug--------------------
Compiling...
38.cpp
E:\ccc\38.cpp(1) : error C2143: syntax error : missing ';' before '<'
E:\ccc\38.cpp(1) : error C2501: 'include' : missing storage-class or type specifiers
E:\ccc\38.cpp(1) : error C2143: syntax error : missing ';' before '<'
E:\ccc\38.cpp(3) : error C2143: syntax error : missing ';' before '{'
E:\ccc\38.cpp(3) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.

38.obj - 1 error(s), 0 warning(s)

error C2143: syntax error : missing ';' before '<'
错误 C2143: 语法错误 :在 '<' 之前 缺少 分号 ;

实际上你这个程序的错误并不是缺少分号,而是 错在第一行 缺少 #
将 include <stdio.h>
改为 #include <stdio.h> 就可以了。

main()
{
float c,f;
printf("请输入一个华氏温度:\n");
scanf("%f",&f);
c=(5.0/9.0)*(f-32);
printf("摄氏温度为:%5.2f\n",c);
}

注意第5行