Statements
Programs are made up of statements.
A statement is either:
- a simple statement
- a null statement
- a control statement
- a block or compound statement
Simple Statement
Null Statement
FORM: ;
EXAMPLE: ;
NOTE: The null statement is rarely used, but it is a legal
statement which means to do nothing. It usually causes
problems for new C programmers. For example, the following
code compiles and executes, but does not produce the desired
effect
/* an unintentional null statement */
while (i > 0);
{
printf ("The value of i is %d\n", i);
i--;
}
Block
{ S1 S2 S3 ... Sn }
where the Si are statements enclosed with braces
Control Statement
What about semicolons ?
- In C, the semicolon is used to terminate a simple statement
- In Pascal, the semicolon separates statements
So that's the rule for semicolons!