The If Statement
The If Statement
The complete syntax of the if statement is:
if (condition) statement;
else statement;
where the targets of the if and else are single statements. The else clause is optional. The targets of both the if and else can be blocks of statements. The general form of the if using blocks of statements is:
if (condition)
{
Statement sequence
}
else
{
Statement sequence
}
Here is a simple example that uses simple if and else statements:
{ if (SomeValue == 0) print("value == 0"); else print("value != 0"); } An else statement always refers to the nearest if statement that is within the same block as that else and not already associated with another else.
|