san*_*ods -2 c++ visual-c++ undeclared-identifier
我是一名初学者C++学习者,我总是在visual studio 2010中的if循环上遇到问题
#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
using namespace std;
int main(void){
string name;
int money;
cout << "Hello, Enter your name here: ";
cin >> name;
cout << "\n\nHello " << name << ".\n\n";
cout << "\nEnter your salary here:L";
cin >> money;
If(money <= 50000 || money >= 100000 );
{
cout << "\nGood!\n";
} else if(money >=49999){
cout << "\nJust begin to work?\n"
} else if(money <= 100000){
cout << "\nWow!, you're rich\n";
}else{
cout << "\nMillionaire\n";
}
system("PAUSE");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并且编译器说'If'标识符无法找到.需要帮助.谢谢
巴拉米
if不指定循环,而是指定条件.请注意,它是小写的if,而不是你拥有的 - If.
此外,您需要删除尾随分号.
这一行:
if(money <= 50000 || money >= 100000 );
Run Code Online (Sandbox Code Playgroud)
什么也没做.
下列:
if(money <= 50000 || money >= 100000 ) //no semicolon here
{
cout << "\nGood!\n";
}
else if(money >=49999)
{
}
Run Code Online (Sandbox Code Playgroud)
如果条件为真,则执行第一个块.