next up previous contents index
Next: 5.5.2 Compound Statements Up: 5.5 Mapping from Programming Previous: 5.5 Mapping from Programming   Contents   Index

5.5.1 Statements

Statements in the C language are categorized into simple statements and compound statements. A simple statement ends with a semicolon ``;'' and cannot be further divided. Here is an example of two simple statements.

i = 0;  // a simple statement
if (i == 0) i = i + 1;  // a simple statement

A simple statement that only contains a semicolon is called a null statement:

;  // null statement

A compound statement is a sequence of statements enclosed by a pair of curly braces. The statements in the curly braces can be simple statements or compound statements.

if (i == 0) {  // a compound statement
    int a = 0;
    a = 1;
    i += a;
}

A compound statement that only contains a pair of curly braces is called empty compound statement.

{  // empty compound statement
}

Statements are the union of simple statements and compound statements.



Thomas Huining Feng 2004-04-28