-
If statement help...
I need some help, with 'if statements'. I can't seem to find the right way to explain it...
Like making my application do something if the input is between 2 numbers.
Code:
if (lvl > 31)(lvl < 71)
{......
......}
Sorry I couldnt explain very well... Thanks to anyone that can help.
-
You are just leaving out the "and" operation.
Think about your problem in plain English first:
"I want to do something if lvl is greater than 31 and lvl is less than 71."
Turning that into C++:
Code:
if ( (lvl > 31) && (lvl < 71) )
{
....code....
}
Notice the only real difference is the "&&".
In C++ "&&" means "and". You can use it in "if" statement to do these kind of things.
-
I think you're looking for:
Code:
if (lvl > 31 && lvl < 71)
{......
......}
The "&&" means AND. So if they are both TRUE, the if statement is executed.