Statements:


A statement in C is the smallest unit executed by the C compiler that causes the compiler to carry out some action. Every statement must end with a semicolon. A program can contain more than one statement. If a program contains more than one statement then they are executed sequentially i.e. the order in which they specified. However, it is also possible to group a sequence of statements by enclosing them into pair of braces; such group of statements is referred as the statement block. The statement block can be named or provided a condition for execution.


There are various type of statements available in C which can be categorized as shown:

Empty Statement:
An empty statement in C is written as a single semicolon (;). It does not do anything but sometimes they are very useful.

Expression Statement:
Expression statements are expressions that end with a semicolon. Most statements in a program are expression statements. These include assignment statements, prefix or postfix statements.

Control Statements:
Control statements change the sequential order of the execution by using selection, iteration and transfer statements. These statements can be classified as follows:
a)      Selection Statements: These statements allow the execution of a block of statements depending upon the value of the Boolean expression or selection among several statements based on the value of Boolean expression or control variable. These statements include if, if- else and switch statements.
b)    

Iteration Statements: These statements allow a statement or a block of statements to be executed repeatedly and have a loop control mechanism that determines how many times the block of statements will execute. These statements include while, do- while and for statements.
c)     

Transfer Statements: These statements transfer control to the beginning of the block, end of the block. These include continue, break, return and goto statements.

There are certain rules applicable to all C statements:
i)                    Every statement in C always ends with a semicolon (;);
ii)                  Usually all statements are written in small case letters.
iii)                Blank spaces may be inserted between two words to improve the readability of the statement. However, no blank spaces is allowed with a variable, constant or keyword.

Previous                                                                                     Next

Powered by Blogger.