Next: Variables, Previous: Defining Typedef Names, Up: Top [Contents][Index]
A statement specifies computations to be done for effect; it does not produce a value, as an expression would. In general a statement ends with a semicolon (‘;’), but blocks (which are statements, more or less) are an exception to that rule. See Blocks.
The places to use statements are inside a block, and inside a complex statement. A complex statement contains one or two components that are nested statements. Each such component must consist of one and only one statement. The way to put multiple statements in such a component is to group them into a block (see Blocks), which counts as one statement.
The following sections describe the various kinds of statement.
• Expression Statement | Evaluate an expression, as a statement, usually done for a side effect. | |
• if Statement | Basic conditional execution. | |
• if-else Statement | Multiple branches for conditional execution. | |
• Blocks | Grouping multiple statements together. | |
• return Statement | Return a value from a function. | |
• Loop Statements | Repeatedly executing a statement or block. | |
• switch Statement | Multi-way conditional choices. | |
• switch Example | A plausible example of using switch .
| |
• Duffs Device | A special way to use switch .
| |
• Case Ranges | Ranges of values for switch cases.
| |
• Null Statement | A statement that does nothing. | |
• goto Statement | Jump to another point in the source code, identified by a label. | |
• Local Labels | Labels with limited scope. | |
• Labels as Values | Getting the address of a label. | |
• Statement Exprs | A series of statements used as an expression. |
Next: Variables, Previous: Defining Typedef Names, Up: Top [Contents][Index]