This section contains 188 words (approx. 1 page at 300 words per page) |
A compound statement, also called a block, joins or brackets together a number of declarations and statements in order to make them into a single statement.
The compound statement is one of the most useful forms of statement. For example, in the C programming language with a conditional statement, the programming syntax dictates that only one statement is allowed in each branch. The use of a compound statement permits several statements to be invoked in a branch.
In specific programming terms, a compound statement is a sequence of statements enclosed in brackets. A generic example of the structure of a compound statement is {declaration-listopt statement-listopt}. A semi-colon is sometimes required before the closing bracket to further define the end of the statement.
Compound statement are used by programmers to form code into blocks so that variables that are placed (declared) within the block become local (unique) to that block.
The compound statement is a major feature in the C++ programming language. Compound statements may be placed anywhere within regular statements and do not always require specific or special termination (e.g., with a semi-colon).
This section contains 188 words (approx. 1 page at 300 words per page) |