Branching Structure
If
If else
Else if ladder
Nested if else
Four decision making statement
if
if-else
else if ladder
nested if else
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
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
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.
Else-if ladder statement
Syntax:
if (condition 1)
{
Statement 1;
}
else if ( condition 2)
{
Statement 2;
}
- - - - - - - - - -
else if (condition n)
{
Statement n;
}
else
{
Statement m;
}
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
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.
THANK YOU

If statements in C

  • 1.
  • 2.
    Four decision makingstatement if if-else else if ladder nested if else
  • 3.
    If statement It isgenerally used when we want to check a single condition. Syntax: if (condition) { Statement ; } START if (condition) Statement END False True
  • 4.
    If else statement Ifthe 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
  • 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.
  • 8.
    Else-if ladder statement Syntax: if(condition 1) { Statement 1; } else if ( condition 2) { Statement 2; } - - - - - - - - - - else if (condition n) { Statement n; } else { Statement m; }
  • 9.
    Else-if ladder statementSTART If (condition1 ) If (condition n) If (condition2 ) False Statement 1 True END True Statement 2 False True Statement n False Default Statement
  • 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.
  • 13.