Stuck

Hi

Please help

So, when i get to this section of code, the while loop doesn't work, the programme just stops, i am wanting the loop to repeat if the user selects anything other than 1, 2 or 3

cout << "Please select your difficulty" << endl << endl;

cout << "1 - Easy" << endl;
cout << "2 - Medium" << endl;
cout << "3 - Hard" << endl << endl;

int difficulty;

do
{
cin >> difficulty;

if (difficulty == 1)
{
cout << "You've chosen the easy way out, i can't say i blame ya!" << endl << endl;
}
else if (difficulty == 2)
{
cout << "So you like a challenge, good for you but big mistake!" << endl << endl;
}
else if (difficulty == 3)
{
cout << "You must be out of your god damm mind!" << endl << endl;
}
else cout << "You have selected an invalid option" << endl << endl;

} while (difficulty != 1 && 2 && 3);
(difficulty != 1 && 2 && 3);

This is a complete misunderstanding of the correct syntax.

I suspect you meant this:
 
(difficulty != 1 && difficulty !=2 && difficulty !=3); 
Ok, thank you, i should have said, i'm new to programming and just learning the basics at the minute, i have changed it as you have suggested, if i select 1, 2, or 3 the loop ends and the programme continues so that's great and one problem solved, but if i say select 4 for example, i am looking to get the message "You have selected an invalid option" and to be asked to select the difficulty again but the programme just stops there and only displays the message "You have selected an invalid option"
Hi, never mind, I've found my problem, the question was never contained within the loop and so would never get repeated, i've changed it and it works
Topic archived. No new replies allowed.