VC++高手帮下忙
来源:百度知道 编辑:UC知道 时间:2024/07/02 20:15:09
小弟刚刚学到函数调用,这道题错在哪啊?照书本例题搬下来也不行的?高手们帮修改一下,谢谢。
#include <iostream>
using namespace std;
double fahrToCelsius(double tempFahr);
int main()
{
cout <<"This progran converts a temperature\n"
"from Fahrenheit to Celsius. \n";
cout <<"\nEnter a Fahrenheit temperature:";
double tempFahrenheit;
cin >> tempFahrenheit;
double tempCelsius = fahrToCelsius(tempFahrenheit);
cout <<tempFahrenheit <<" degrees Fahrenheit is equivalent to"
<<tempCelsius <<"degrees Celsius\n";
}
double fahrToCelsius(double tempFahr)
{
return (tempFahrenheit-32.0)/1.8;
}
#include <iostream>
using namespace std;
double fahrToCelsius(double tempFahr);
int main()
{
cout <<"This progran converts a temperature\n"
"from Fahrenheit to Celsius. \n";
cout <<"\nEnter a Fahrenheit temperature:";
double tempFahrenheit;
cin >> tempFahrenheit;
double tempCelsius = fahrToCelsius(tempFahrenheit);
cout <<tempFahrenheit <<" degrees Fahrenheit is equivalent to"
<<tempCelsius <<"degrees Celsius\n";
}
double fahrToCelsius(double tempFahr)
{
return (tempFahrenheit-32.0)/1.8;
}
在
double fahrToCelsius(double tempFahr)
{
return (tempFahrenheit-32.0)/1.8;
}
这个函数中的 tempFahrenheit 没有定于啊 所有这个函数要改成
double fahrToCelsius(double tempFahr)
{
return (tempFahr-32.0)/1.8;
}
就OK了 记住,每一个变量都要先声明后使用
cout <<"This progran converts a temperature\n"
"from Fahrenheit to Celsius. \n";
这一句不对吧.
cout <<"This progran converts a temperature\n" <<"from Fahrenheit to Celsius. \n";
double fahrToCelsius(double tempFahr)
{
return (tempFahr-32.0)/1.8;
}
int main()改成 void main()