I am having trouble getting this or operator to work.
From what I can tell the line that uses the input asks:
"If the userkey is equal to 88 or is equal to 77 then print "Login" else
print "Invalid".
I have better results when I use letters, though for the life of me I cannot work out why this isn't working.
It is the Or operator and I feel I may be confused as to what it is actually doing.
the logical OR operator works like a function internally. It's syntactic sugar.
take this step-by-step.
if(userkey == 88 || 77)
relation operator == returns a booleanif( [true/false] || 77 )
the logical operator || checks to see if either or both of the operands are a nonzero value and returns true if so.
Even if the precedence for || was higher, you'd be looking at 88||77, which would be true no matter what.