Re: What's wrong with this??
if(whereToGo == 1);
Your braces don't look right in your else and second if statement either.
Re: What's wrong with this??
Grr i tried to fix it but i still don't get it :P
Re: What's wrong with this??
Quote:
Originally Posted by
jesus45
Grr i tried to fix it but i still don't get it :P
What did you try? I assume you got the point that your if statements shouldn't be terminated with a semi-colon?
Re: What's wrong with this??
this is what i have now.
Code:
int whereToGo;
do {
cin >> whereToGo;
if(whereToGo == 1);
cout << " You go outside and you are stopped by a guard.\n";
cout << " He asks you to go on a quest for him";
}
else
if(whereToGo == 2);
cout << " You have chosen to stay and look around\n";
cout << " You look around the castle is made of marble\n";
cout << " There are wealthy people all around you\n";
} while (whereToGo < 3);
Still doing something wrong though.
Re: What's wrong with this??
Quote:
Originally Posted by
jesus45
this is what i have now.
Code:
int whereToGo;
do {
cin >> whereToGo;
if(whereToGo == 1);
cout << " You go outside and you are stopped by a guard.\n";
cout << " He asks you to go on a quest for him";
}
else
if(whereToGo == 2);
cout << " You have chosen to stay and look around\n";
cout << " You look around the castle is made of marble\n";
cout << " There are wealthy people all around you\n";
} while (whereToGo < 3);
Still doing something wrong though.
Again - sigh - don't put a semi-colon after your if statement.
Anything you want to execute if the if statement is true should be enclosed in a block using braces.
Code:
if(whereToGo == 1)
{
cout << " You go outside and you are stopped by a guard.\n";
cout << " He asks you to go on a quest for him";
}
Re: What's wrong with this??
int whereToGo;
while ((whereToGo !=1) || (whereToGo!=2))
{
cout<<"Enter I/p"<<endl;
cin >> whereToGo;
if(whereToGo == 1)
{
cout << " You go outside and you are stopped by a guard.\n";
cout << " He asks you to go on a quest for him";
break;
}
else {
if(whereToGo == 2)
{
cout << " You have chosen to stay and look around\n";
cout << " You look around the castle is made of marble\n";
cout << " There are wealthy people all around you\n";
break;
}
}
}
Re: What's wrong with this??
((whereToGo !=1) || (whereToGo!=2))
Think about that. See if you can come up with a number where that is never true.