First script could I make it any better

Pages: 12
The OR-statement works like this: if either of the options or both of them are true then it will be true. I will show it with 1's and 0's, to make it easier to grasp.

OR-statement
Think it like A+B = Y where A or B have to be 1 to make the result Y 1.

A+B=Y
0+0=0
0+1=1
1+0=1
1+1=1

(0 = false and 1 = true)

And when you add the (!=) it makes it:
___
A+B=Y
0+0=1
0+1=1
1+0=1
1+1=0

And if I understood correctly about what you were trying to acomplish then just remove the qu != statement and make it like: while (qu == 'Y')

I hope this helped, as it was my first post! :3
You wanted one of the below (which evaluate to the same thing):
1
2
while( !(qu == 'N' || qu == 'Y') ) {...} //Read: while qu is not 'N' or 'Y'.
while( qu != N && qu != 'Y' ) {...} //Read: while qu is not 'N' and qu is not 'Y'. 


See what you had was:
1
2
3
4
while( qu != 'N' || qu != 'Y' ) {...} //Which is read: while qu is not 'N' or qu is not 'Y'. This is equivalent to saying
while( !(qu == 'N' && qu == 'Y') ) {...} //Which is read: while qu is not 'N' and 'Y'.
                                         // This makes no sense though. qu can never be both 'N' and 'Y' because it's one character,
                                         // and therefor it will always be not 'N' and 'Y'. 

Last edited on
Topic archived. No new replies allowed.
Pages: 12