C++ F转到C, 为什么不可运行说Error3 error C4700: uninitialized local variable 'Celsius' used

int_tmain(intargc,_TCHAR*argv[]){floatFahrenheit;//toholdtemperatureinFahrenheitcharC... int _tmain(int argc, _TCHAR* argv[])
{
float Fahrenheit; // to hold temperature in Fahrenheit
char Celsius; // to hold temperature in Celsius
// set the numeric output formatting.
cout << fixed << showpoint << setprecision(1);
// Display the table headings.
cout << "Fahrenheit\ tCelsius " << endl ;
cout << "---------------------" << endl ;
//Display the temperature.
for (Fahrenheit = 0.0; Fahrenheit <= 100.0; Fahrenheit += 10)
{
// Calculate Celsius
Fahrenheit = (5.0 / 9.0) * (Fahrenheit - 32);
// DDisplay the temperature in Fahrenheit and Celsius.
cout << Fahrenheit << "\t" << Celsius << endl;
}
return 0;
}
展开
 我来答
xoaxa
推荐于2016-06-14 · TA获得超过8613个赞
知道大有可为答主
回答量:6415
采纳率:72%
帮助的人:3633万
展开全部

#include "stdafx.h"
#include <iostream>
#include <iomanip>

using namespace std;

int _tmain(int argc, _TCHAR* argv[]) {
double Fahrenheit;     // to hold temperature in Fahrenheit
double Celsius;     // to hold temperature in Celsius
// set the numeric output formatting.
cout << fixed << showpoint << setprecision(1);
cout << setw(12);
cout.setf(ios_base::right,ios_base::adjustfield);
// Display the table headings.
cout << "Fahrenheit(°F) -- Celsius(°C)\n";
cout << "---------------------\n";
//Display the temperature.
for (Fahrenheit = -40.0; Fahrenheit <= 110.0; Fahrenheit += 10) {
// Calculate Celsius
Celsius = (5.0 / 9.0) * (Fahrenheit - 32);
// DDisplay the temperature in Fahrenheit and Celsius.
cout << setw(6) << Fahrenheit << "\t" << setw(12) << Celsius << endl;
}
return 0;
}
追问
已经解决了,太谢谢你啦:)
追答
char Celsius; -> double Celsius;

Fahrenheit = (5.0 / 9.0) * (Fahrenheit - 32); -> Celsius = (5.0 / 9.0) * (Fahrenheit - 32);
phyxnj
2014-05-21
知道答主
回答量:15
采纳率:0%
帮助的人:11.5万
展开全部
Celsius 这个变量没初始化
追问
昂~应该如何改呢?不太懂这些,是个选修课- -好头疼
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
huangking321
2014-05-21
知道答主
回答量:34
采纳率:0%
帮助的人:6.5万
展开全部
‘Celsius’ 这个变量 你用到了吗?
追问
我也不太懂这些东西,我是照着KPH到MPH弄的,不知道哪里出了问题。就是想运行出来显示
Farenheit Celsius
-------------------------------
0.0 -17.8
10.0 -12.2
一直到100
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式