My question is how to implement Boolean in an IF statement with YES or NO?

("Do you want to re-start? *YES*=restart(for loop?) *NO*=exit")

09-02-2005

DougDbug

Well, you can't compare strings using the boolean operators. You can only compare numbers.

In your simple yes / no example, the best option is to check to see if the first character is "Y' or "N". You can use boolean for this, because each ASCII character is represented by a number... you are just comparing numbers.

You need to understand strings (C-style strings or C++ string objects) and you need to understand the ASCII code.

Some hints:
- Check for both upper and lower case.

- If there are two conditions, you only need to check one... If "yes" is the default answer, just check for "N" or "n". If the user enters anything other than that, assume "yes".

Even if there are more than 2 choices, I'll usually have a default value so I can just hit ENTER. If there is no default, you need to repeat the question if the user enters something invalid.

09-02-2005

swoopy

>My question is how to implement Boolean in an IF statement with YES or NO?