Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

The If Statement: Difference between revisions

From Catglobe Wiki
Cg_pham (talk | contribs)
No edit summary
Cg_pham (talk | contribs)
No edit summary
 
Line 1: Line 1:
[[Category:Program_Control_Statements]]
[[Category:Program_Control_Statements]]

{{HelpFiles}}


===The If Statement===
===The If Statement===

Latest revision as of 07:15, 14 December 2011



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.