3. If statement
It is generally used when we
want to check a single
condition.
Syntax:
if (condition)
{
Statement ;
}
START
if
(condition)
Statement
END
False
True
4. If else statement
If the given condition is true, then the
“if” block of code will be executed,
otherwise “else” block of code will be
executed.
Syntax:
if (condition 1)
{
Statement 1;
}
else
{
Statement 2;
}
START
If
(condition)
Statement 1
True
False
Statement 2
END
5.
6.
7. Else-if ladder statement
• The “else if” ladder is used to test set of conditions in a
sequence. It is also considered as multi-way decision
making statement.
• Number of conditions are given in a sequence with
subsequent statements. If any of the given condition is
satisfied then the related statements are executed and the
control exits from the else if ladder. That means further
conditions are not going to checked.
• If the condition does not satisfy then the compiler goes to
next condition to check the condition.
9. Else-if ladder statement START
If
(condition1
)
If
(condition
n)
If
(condition2
)
False
Statement 1
True
END
True
Statement 2
False
True
Statement n
False
Default
Statement
10.
11. Nested if-else statement
• Writing if statement inside another is known as nested if.
• While writing number of conditions, we may need to nest if
statement inside another if statement.