Conditional Branches?

Anybody know much about these?
id like to create a programn where you can say something for example:

Programn: Are you okay?
User: Yes

If yes: Programn: Thats great to hear

If no: Programn: Sorry to hear that

Thanks in advance!
You can do it with an if/else combination but to achieve have a program with a lot of question and possible answers it would be frustrating.
Maybe just basic short questions? i mean is their a limit?
I don't think there is an arbitrary limit but most books suggest using switch() and case : to avoid more than 5 or 6 if()/else if()/else's because of the potential difficulty of achieving matching braces.
Problem with switch statements is that you need to have an integer in the switch. Of course you can use strings and the string.find(string) function in the class of string to help you search strings for potential replies.

Say someone types in a long string but puts in hello. If you search for hello (lowercase or uppercase everything before searching for easier searches since this is case sensitive) and there is a hello, you can respond that way.

If statements is the only way you can go with strings sadly, but you can use else if so that if something is already found, it will skip the rest of the else if codes.
Topic archived. No new replies allowed.