Simple if statement in C language


If Statement in C Language

If statement is a very powerful decision making statement and it is used to control the flow of execution of statements. It is basically a two way decision making statement and it is used with a relational or logical expression. There are four types of if statement:

  • Simple if
  • If else
  • Nested if
  • If else if ladder

Simple if statement in C language

 In simple if statement, there is only one Condition and depending upon the Condition, a particular set of statements will be executed. The syntax of simple if statement is:


Condition is any relational or logical expression which will be checked to evaluate whether statements of C language specified by “Statement-Block” will be executed or not. If this condition is true, only then Statement-Block will be executed. If  condition is false, Statement-Block will not be executed.

Statement-Block  is a set of C language statements, which will be executed if condition is true. It must contain valid statements of C language.

Statement-X  may be a single statement or a group of statements which will always be executed in both the cases of condition to be true as well as false.

Simple if statement can be represented with the help of a flowchart as :

Simple if statement in C language

Program to demonstrate the use of simple if statement
int a=10;
printf(“number is +ve”);
Number is +ve

Description of Above program

In the above program, a is 10. 

Condition a>0 is true so very next statement after if(a>0) would be executed i.e. printf(“number is +ve”) followed by printf(“\nBye”).

In case, condition becomes false. Only printf(“\nBye”) would be executed.

Lesson tags: if statement in c, simple if statement in c, types of if statement in c
Back to: C Programming Language