
|
The if statement is used to perform an action depending on a condition. Syntax:
if (condition) // run code
The condition is boolean - true or false. 1 is true, and 0 is false. Here's a working example of the if statement:
if (i == 5) PrintInt(i);
In this case, i == 5 is the condition. If the variable i is equal to 5, the Relational Operator '==' will return 1 for true. If not, it returns 0 for false.
If the condition returns true, the code is run. But if the condition returns false, the statement or code block following the if statement will be ignored.