Programming

C – Statements and Types of Statements

Any line written in a ‘c’ editor that normally terminates by a semicolon ‘;’ is  called statement.

int a,b,c,d=55;
float rate;
char n; 

Null Statement

If you place a semicolon by itself on a line, you create a null statement-a statement that doesn’t perform any action, that is known as a null statement. This is perfectly legal in C. 

: - null statement

Expression Statement

An expression statement is a constant, variable or combination of constant variable. This can also include a function call.

An expression statement consists of any valid C expression and followed by a semicolon. 

a=b; expression statement
c=a+b; expression statement
greater(a,b,c); functional statement

Compound Statement

A compound statement, also called a block, is a group of two or more C statements within a pair of braces ( { and} ).

Unlike an expression statement, a compound statement does not end with a semicolon. 

{
        printf("Hello,");
        printf("World");
}

In C, a block can be used anywhere a single statement can be used.

Control Statement 

Control statements are used to create special program features, such as logical tests, loops and branches,

if(a>b)
                  printf("A is greater");
else
                  printf("B is greater");

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.