General > Micro-IDE

Using logical OR in a while statement?

(1/1)

Espallator:
Can I use the logical OR operator in a while statement? How?
I tried like:
while(c != \'1\' || c != \'2\')
{...}
or
while((c != \'1\')||(c != \'2\'))
{...}

but it doesn\'t work. The weird thing is that
while(c != \'1\')
{...}
it works!

Espallator:

--- Quote ---Can I use the logical OR operator in a while statement? How?
I tried like:
while(c != \'1\' || c != \'2\')
{...}
or
while((c != \'1\')||(c != \'2\'))
{...}

but it doesn\'t work. The weird thing is that
while(c != \'1\')
{...}
it works!
--- End quote ---

I solved it! I just changed || for && and its working. ;D

Navigation

[0] Message Index

Go to full version