D:\我的文档\C语言的文件\作业3.c(6) : error C2018: unknown character '0xa1'
D:\我的文档\C语言的文件\作业3.c(6) : error C2018: unknown character '0xa2'
D:\我的文档\C语言的文件\作业3.c(9) : error C2001: newline in constant
这个是因为printf("Please input a number");、多了一个、号
后面的错是因为你f这个函数没定义类型
#include
void main()
{
float f(float x);
float a,b;
printf("Please input a number");
scanf("%f",&a);
b=f(a);
printf("another nunber is %.2f\n",b);
}
float f(float x)
{
float y;
y=(x-32)/1.8;
return(y);
}
正确的是这样的 对了printf("another nunber is %.2f\n",b);你少加了“
#include
void main()
{
float f(float x);
float a,b;
printf("Please input a number");//此处你多打了个(顿号)、号
scanf("%f",&a);
b=f(a);
printf("another nunber is %.2f\n",b);//此处你忘记了“号
}
float f(float x)//此处你忘记写函数返回值类型
{
float y;
y=(x-32)/1.8;//最好用double型,不过没影响,会报告一个警告
return(y);
}
真正原因并不是x, y没定义, 代码里有几处错误,
1 f函数定义没有给出返回类型float,
2 printf("Please input a number");、多了一个字符“、”
修改以后可以编译运行,附上修改后代码;
#include
void main()
{
float f(float x);
float a,b;
printf("Please input a number");
scanf("%f",&a);
b=f(a);
printf("another nunber is %.2f\n",b);
}
float f(float x)
{
float y;
y=(x-32)/1.8;
return(y);
}
printf("Please input a number");、
这一句后面躲了个顿号 去掉就ok 改为
printf("Please input a number");
你函数声明的时候缺少返回类型:
float f(float x){
float y;
y=(x-32)/1.8;
return(y);
}
#include
问题还挺多,对比看。