Quick question about 'if' statements

I can I have many consecutive conditions

Example:

if (ans=="yes"; ans=="Yes"; ans=="YES"; ans=="yES"; ans=="yeS")


If not then how would I do something like that without have to make a billion

if (yes)
{This is an example but something would go here}

else if (Yes)
{Isn't this fun? thanks for helping me}
Last edited on
You can have multiple conditions, but you need to join them with logical operators. In your example, it seems you want to enter the statement block if any one of the conditions is true, so you would use OR, which is ||, instead of the semicolons.
The problem is solved by performing case-insensitive string comparisons. One way to do that is to transform both strings to lower or upper case first, then compare them normally. The functions tolower and toupper will help you in writing such a function.
Topic archived. No new replies allowed.