if statment

an If statement that would have choices from 1-to what ever number included in it
such as

if ( (choice == 1 then the rest of the choices)

can it be lik 1;2;3;4 and so on, or is it something else
You will want to use a switch statement.
If you want a range of numbers you can use >=, <= operators:

 
if((choice >= 1)  && (choice <= 4))


Well allow all numbers between 1 and 4.
@mrharris10 do you know the range of "1-to what ever number included in it" or is this something that will be dynamically defined?

maybe a for loop?

1
2
3
4
5
6
7
8
cin>>choice;
cin>>max;
for( int i=0; i < max; i++ )
{
     if( choice == i )
     {
     }
}


elaborate please!
A for loop?

He could just use >=

1
2
3
4
if((choice >= 1) && (choice <= max))
{
  //...
}
Thanks guys, but for this project i may just have to use a switch statement.
But thanks for the info, this would be useful later on.
Topic archived. No new replies allowed.