C Programming Tutorial 8, If Statement Pt.3

Now let me just go ahead and show you one more thing right here we did or you can also do and so what we can do is change these two two and symbols and yes you do need.

To and symbols right here so make sure that you put two and now what it’s going to say is if my character equals.

Capital A and my character equals capital B and my character equals.

Capital C then I’ll print out hello well that’s impossible my character cannot be equal to a B and C but if you were trying to test three conditions like.

You’re trying to test like if my character equals capital a and then some other variable equals 10 then we want to print out hello so let’s go ahead and change it to that so we’re going to create another integer variable up here so we’re going to say int I equals 10 and then what.

We’re gonna do is just delete all this right here and we’re going to say if the character that the user enters is a and this variable called I is equal to 10 then we want it to print out hello so now if the user enters a we should get hello because I is equal to 10 right up.

Here so we’re gonna say hey yep we get hello because the character that the user entered was a and the value.

Of I is 10 but now let’s go ahead and change the value of I to something besides 10 like 6 and run this we enter capital a and we see we get you entered an invalid character because what it did right here is like all right my character is equal to capital a but I is not equal to 10 so it just went down here and printed you entered an invalid character so the only way that’ll print this hello.