I'm new to C++, and i have created this program. The problem is when I try to compile, it says the the "else" at the end needs a ;. This doesnt make sense.
Also, im using bloodshed DevC++.
include <iostream>
using namespace std;
int hackeralert()
{
string answer;
cout<< "Are you a hacker? (Yes or No)\n";
cin >> answer;
if (answer== "yes")
{
cout<< "COME OUT OF THE BUILDING WITH YOUR HANDS UP!\n";
getchar();
}
else
{
cout<<"You must just be an idiot.\n";
getchar();
}
}
int main()
{
int thisnumber, thisnumber2, x, thing;
string password;
thing = 1;
cout<< "What is your password?\nIf you answer wrong, the program will close.\n";
cin>> password;
if (password == "Open")
{
cout<< "Please enter a number between 1 and 100. If you enter a letter, this will shut down.\n";
cin >> thisnumber;
}
if (thisnumber == 72);
{
cout<< "Good Job!\n";
getchar();
}}
else
{
cout<< "FAIL.\n";
}
One of the braces on the fifth to last line belongs at the end.
If you use proper indentation, things like that cannot happen.
The semicolon four lines above that doesn't belong there either.