Jedi Knight will think that the if statement is finished and will begin executing the block of statements that follow the if , whether or not the relational test is true or false. OK, so let's put this into practice now. But that's more work than is necessary. It's much easier using the logical operators. Here's how we'd do it using logical operators.
Logical operators are very useful for if statements.
The else statement determines what happens if the relation is false . The if , as you already know, determines whether or not a block of code runs, but it's possible to extend the action of if so that it runs one block of code or another depending on the result. To do this, we simply need to add the else statement after the if 's closing brace. The else statement runs only if relationalTest is false. Now, we'll move on to some of the other C elements .