-
WHILE LOOP problem
uggg....oh man i will probably figure it out before anybody respods but just incase i don't here's my problem. it's soo anoying
i'm asking the user to enter n (notice small) if they don't want the program to continue, but when they press 'N' (notice capital) my loop just continues. so i tried fixing it with this statement:
while(ch!='n' || ch!='N')
but now the problem is that the loop continues if the user enters n or N. not what i want. i want the program to exit when the user enters n or N. any thoughts on this would be greatly appreciated. thx
-
while(ch!='n' && ch!='N')
-
... or use toupper() and then only test against capitals.
-
ok, thanks to polymorphic, i used && instead of || (if you don't know what i'm talking about read my problem up top) . but why &&?
-
|| is "or"
&& is "and"
Read the logic of the test, and you should understand. You want both tests to be true to keep the loop going.
-
YES HAMMER!!!! THANK YOU SOOOOO MUCH!! IT ALL MAKES SENSE NOW!! WQOOOOHOO! I'M SO HAPPY! THANK YOU SOO MUCH!!!!!!!!!!!!!!!!!!!!!!!!!
the last few words in your reply made all the difference in my understanding!
oh my blush! thanks alot!