php
iphone
css
c
xml
ajax
linux
android
objective-c
multithreading
flash
html5
perl
algorithm
facebook
apache
php5
asp
api
jsp
The || doesn't quite mean what you think it means. The correct approach is:
||
if (yesno != 'Y' && yesno != 'N') { ...
This evaluates each side of the && independently, and the result is true if both sides are true.
&&
Note that
if (yesno != 'Y' || yesno != 'N') { ...
will always be true because any given character is either not Y or it is not N. This is probably not what you want.
if(yesno != 'Y' || 'N')
should be:
if(yesno != 'Y' && yesno != 'N')
You are chaining them which is incorrect. I am fairly sure you know that you should not and that is a typo, because you used && correctly on line no 44.
44
Take the conditional yesno != 'Y' || 'N' apart. It has two clauses:
yesno != 'Y' || 'N'
yesno != 'Y'
yesno
'Y'
'N'
So you have "(stuff) || (always true)". Here "stuff" is yesno != 'Y' and "always true" is 'N'. The result will always be true.
you cannot OR an expression (yesno!='Y') and a statement ("N") which is also an expression. its only two or more expressions that can be combined using || and && to get the required output.
if(yesno!="Y"||"N")
is actually
if(yesno!="Y" || TRUE)
which is always true because:
Exp||TRUE=TRUE
regardless of the expression.
use if(yesno!="Y"|| yesno!="N") // and in this case its && and not || i think
You need to put
if (yesno != 'Y' || yesno != 'N')
You always need to put the full expression twice.