0

How would I loop a switch statement until one of the valid options are entered.

would this work?
example:

// lets just say all the necessary starting code is already here....

       int choice, number;
do
{
       cout<<"please enter a number from 1-3\n";
       cin>>number;
       switch(number)
       {
             case 1:
               break;
           blah blah blah
}
while(number != 1 || number != 2 || number != 3 );
return 0;
}

Sorry if I confused someone with this I just need some help with looping a switch statement.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by WaltP
0

You should probably use a while statement with a flag variable and a few if's.

while(Requirmet not met)
{

    cout << "Enter info";
    cin >> info;

    if(  )
        {
         ////do stuff
          Req met;
         }

etc...


}

Edited by LevyDee: n/a

0

How would I loop a switch statement until one of the valid options are entered.

would this work?

It will work fine if you set up the while condition correctly. Your condition is always TRUE.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.