【发布时间】:2015-10-01 03:22:45
【问题描述】:
我尽了最大努力,但无法弄清楚我的代码出了什么问题。
我收到一个错误代码"error: expected ' ; ' after return statement."
注意:这是我除了“hello world”之外的第一个程序,任何帮助将不胜感激。
#include <iostream>
using namespace std;
int main() {
int celsius, fahrenheit;
//Get degrees in celsius
cout << "Please input degrees Celsius: \n";
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
//display degrees farhenheit/ thank you message
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
cout << "\n" << "Thank you for using my Celsius to Fahrenheit converter. \n" << "\n";
{
int yes = 1, no = 0;
cout << "do you wish to convert again? \n";
cin >> yes;
if (yes == 1) {
return cout << "please enter degrees Celsius" ;
cin >> celsius;
//convert celsius to fahrenheit
fahrenheit = celsius * 1.8 + 32;
cout << "\n" << "Degrees Fahrenheit: \n" << fahrenheit << "\n";
} else {
return cout "fine";
}
}
return 0;
}
【问题讨论】:
-
你也有不必要的大括号
{ }。
标签: c++ compiler-errors