Compound Statements

Compound statements are statements that contain lists of statements enclosed in braces. The enclosed list should be tabbed over one more than the tab position of the compound statement itself. The opening left brace should be at the end of the line beginning the compound statement and the closing right brace should be alone on a line, tabbed under the beginning of the compound statement. Note that the left brace beginning a function body is the only occurrence of a left brace which is alone on a line.


Note that the right brace before the else and the right brace before the while of a do-while statement (below) are the only places where a right braces appears that is not alone on a line.

Note that when multiple case labels are used, they are placed on separate lines. The fall through feature of the C switch statement should rarely if ever be used when code is executed before falling through to the next one. If this is done it must be commented for future maintenance.

The last example is a generalized switch statement and the tabbing reflects the switch between exactly one of several alternatives rather than a nesting of statements.