Welcome back to another video. In this video, I'm going to demonstrate if else statements to you. And so what you're looking at are some nested if else statements. And I'll show you about the rules associated with them. And so we have the main program, integer main, and the main program has opening and closing brackets. I'm moving those over to make them more clear. And then we have integer i is equal to 10. We're just going to create a variable, make it something that we can test with. Now, if i is equal to 10, this is a comparison operator, not an equality, not an assignment expression. Excuse me, this is just testing for equality or comparison. So, and then the if statement always has a Boolean that shows up in the middle here. So if i is equal to 10, then we have an opening and a closing bracket that's going to cover this whole if statement. Now inside, I've left the if statements off. And the reason why I've done this is just to illustrate a point to you that if it's one line, you don't actually have to put the curly brackets in. So if i is equal to 10, which it is, then this code here will run. And this is the first if statement inside of the nested if statements. If i is less than 15, which it is, then we're going to see out i is smaller than 15. And then we're going to say, we're going to continue. And this will only execute if the statement above is true. Then we're going to get if i is less than 12, then we're going to print out which it is. Because it's equal to 10, i is smaller than 12 too. Else would print out i is greater than 15. Now this whole thing is not going to run unless i is equal to 10. So if I run it, I can sort of see how this works. And I can see that i is smaller than 15 and that i is smaller than 12 too. Both of them print out because i is equal to 10. Now if I made i equal to 20 and I run it, which is not equal to 10, I'm going to notice some interesting behavior. No behavior at all. Nothing prints out because this whole entire block is skipped and we just return. So I can put an else on the outside here and just say else. And the else that I'm putting on the outside is on the outside of the outer if that says, if i is equal to 10, do all this stuff. If not else, I'm going to indent this in so it's easier to read. And else let's see, let's see out i is larger than 10. See out i is larger than 10. So I'll see out i is larger than 10 because i is equal to 20. And so if I run it this time, then I'm going to get something printed to the screen that's going to say that i is larger than 10 instead of absolutely nothing being printed to the screen. You can put if else is together in combination, you can nest them inside of each other if you'd like. You can put other things inside multiple lines. If you're using multiple lines of code, you need to include the opening and the closing brackets. If it's just one single line of code, you can put it on the line underneath and you don't need opening and closing brackets, but it's safer to put them in like I've done here just to be on the safe side. So that is how you use if and else statements. We've seen them before and we'll see them again. They come up quite often in programming. Thanks for watching.