Program Statement
A statement is a syntax construct that executes an action upon execution of a program. C Programs statements are terminated with a semi-colon(;).
A program statement in C are classified as:
- Declaration statement
- Expression statement
- Compound statement
- Labelled statement
- Control statement
- Selection
- Iteration
- Jump
Declaration statement:
The declaration statement is a program statement for communicating to a language translator about the name and type of variables.
Example:
int x;
Expression statement:
It is a program statement made up of a sequence of operators and operands that specifies the calculation.
Example:
c=a+b*c;
Compound statement:
The compound statement is a sequence of statements that can be treated as one statement in building more important statements.
Example:
if(c==1) { x=x+1; y=y*3; }
Labeled statement:
The labeled statement can be used to mark any statement so that control can be passed to that particular statement.
Example:
L1: c=c*3; n=n-1; if(n>0) goto L1;
Control statement:
It is a statement where the performance of which results in a choice between two or more paths to follow.
Different types of control statements are:
Selection statements:
These let a program select a specific execution path from a set of one or more alternatives.
Example:
if..else statements.
Iterative statements:
These are used to run one or more statements multiple times.
Example:
while, for, do-while.
Jump statement:
It results in an unconditional jump to another place of the program.
Example:
goto.