1. ## While

Is there a way to check for more than one
variable in a while statement
like
while (number1 == number2)

Ruffly put, that would check for 2 number being equal,,
how could I add a 3rd, or a 4th or even a 5th number
in that while statement?
In other words a way to check for 5 number being the
same.

Thanks

X

2. while (number1 == number2 && number1 == number 3)

3. oooorrrrr

while (vari1 == vari2 && vari1 == vari3 && vari1 == vari4)

4. IC thanks..guys,but one question
will thisl check if all the numbers are not equal to each other..
or does it just see if the 1st number is not equal to the rest?

5. Write a for loop to test every possible comparison.

[EDIT]
BTW, this type of question should have answers all over the web.
[/EDIT]

6. Shadow's right. Locating a "truth table" should be no problem at all, and should give you the insight needed to answer your question.

A little snippet to get you started:

'while ( x == y || y == z)' will pass the test even if y = 1 and z = 0 provided that x does, in fact, equal y.

The use of the logical-OR (||) dictates that only one comparison evaluate to "true" in order to pass the test. Therefore, as soon as a "true" condition is encountered, the remainder are ignored, i.e. not even evaluated.

You will really want to watch out for the logical-NOT (!) being thrown into the mix. You will have, at least, one conversation with yourself, I'm sure.

-Skipper

7. Originally posted by skipper
Shadow's right. Locating a "truth table" should be no problem at all, and should give you the insight needed to answer your question.

A little snippet to get you started:

'while ( x == y || y == z)' will pass the test even if y = 1 and z = 0 provided that x does, in fact, equal y.

The use of the logical-OR (||) dictates that only one comparison evaluate to "true" in order to pass the test. Therefore, as soon as a "true" condition is encountered, the remainder are ignored, i.e. not even evaluated.

You will really want to watch out for the logical-NOT (!) being thrown into the mix. You will have, at least, one conversation with yourself, I'm sure.

-Skipper
reminds me of a colorful discussion i had with myself a few days ago about logical and vs bitwise and

Popular pages Recent additions