我試過我的水平最好,但無法弄清楚我的代碼出了什麼問題 我得到一個錯誤代碼"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;
}
您有不必要的括號'{}'太。 – kemotoe