-
November 3rd, 2012, 08:18 AM
#1
Need help with a logic error please.
while ((answer != 'A') || (answer != 'B') || (answer != 'C') || (answer != 'D'))
This section of code accepts no answer, instead of just A B C or D.
Any thoughts on how I should do this?
Thanks/
-
November 3rd, 2012, 09:48 AM
#2
Re: Need help with a logic error please.
Think about it a bit. Since you're using logical or ||, if any of those conditions is true, the expression is true.
Say answer is 'A'. If it's 'A', it's not 'B', so the expression is true. So instead of any of those conditions being true, you want all of them to be true. Think about what you may need to change to accomplish that.
-
November 3rd, 2012, 11:04 AM
#3
Re: Need help with a logic error please.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|