c/language/statements

Statements are fragments of the C program that are executed in sequence. The body of any function is a compound statement, which, in turn is a sequence of statements and declarations:

There are five types of statements:

@1@ compound statements @2@ expression statements @3@ selection statements @4@ iteration statements @5@ jump statements

Labels
Any statement can be labeled, by providing a name followed by a colon before the statement itself.

@1@ Target for. @2@ Case label in a statement. @3@ Default label in a statement.

Any statement (but not a declaration) may be preceded by any number of labels, each of which declares to be a label name, which must be unique within the enclosing function (in other words, label names have ).

Label declaration has no effect on its own, does not alter the flow of control, or modify the behavior of the statement that follows in any way.

Compound statements
A compound statement, or block, is a brace-enclosed sequence of statements and declarations.

The compound statement allows a set of declarations and statements to be grouped into one unit that can be used anywhere a single statement is expected (for example, in an statement or an iteration statement):

Each compound statement introduces its own.

The initializers of the variables with automatic declared inside a block and the VLA declarators are executed when flow of control passes over these declarations in order, as if they were statements:

Expression statements
An expression followed by a semicolon is a statement.

Most statements in a typical C program are expression statements, such as assignments or function calls.

An expression statement without an expression is called a null statement. It is often used to provide an empty body to a or  loop. It can also be used to carry a label in the end of a compound statement or before a declaration:

Selection statements
The selection statements choose between one of several statements depending on the value of an expression.

@1@ statement @2@ statement with an else clause @3@ statement

Iteration statements
The iteration statements repeatedly execute a statement.

@1@ loop @2@ loop @3@ loop

Jump statements
The jump statements unconditionally transfer flow control.

@1@ statement @2@ statement @3@ statement with an optional expression @4@ statement