Does this coding take all int values? |
You don't give us the types for the random variable, we therefore cannot say if it takes int values.
I mean, can number 3 be part of this if statement? |
It can indeed take three, however it will always return true, no matter what number you enter. The reason this is is because you use the
||
operator. What your code is saying is that if random is greater than/ equal to six
or less than/ equal to nine, the statement is true. So anything greater than six or less than nine fits, but everything is greater than six or less than nine (three is less than nine, 100 is greater than six for example)
To combat this, you need to use the
&&
operator. It will check to see if random is greater than/ equal to six
and less than/ equal to nine, giving a range of six to nine. In this case, three would not be a true statement as it is less than six.