Decision Making
 Selcetion statements
Decision Making
C has three major decision making instructions—the if statement, the
if-else statement, and the switch statement.
 The decision control statements are the decision making statements
that decides the order of execution of statements based on the
conditions.
if
if-else
else-if
nested if else
switch case statment
Introduction
Conditional Statements are Used to Execute a set of Statements On some
Conditions.
It provides a unit of Block In which we can Either one statement or more
than one statements.
if the given condition is true then the set of statements are executed
otherwise body is skipped.
If Conditions
If is conditional statement, which is used to execute a set of statement on
some conditions.
The condition must be of Boolean type expression.
An expression, which returns only two value either True or False is known as
Boolean type expression.
Syntax:
if (condition)
{
//Block of C statements here
//These statements will only execute if the condition is true
}
Flow Diagram of if statement
If Else Condition
It is known as double blocked conditional statements.It means,it has
True Parts as well as False part.
If the given condition is true then the true part is executed otherwise
flase part is executed.
Synstax:
if(condition) {
// Statements inside body of if
}
else {
//Statements inside body of else
}
Flow Diagram of if else statement
nested-if
Using of one if statement within another if statement is know as nested
of if else statement.
Syntax:
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}
Flow Diagram of nested-if statement
if-else-if ladder
 A user can decide among multiple options.
 The C if statements are executed from the top down.
 As soon as one of the conditions controlling the if is true,
 the statement associated with that if is executed, and the rest of the C else-if ladder is bypassed.
 If none of the conditions are true, then the final else statement will be executed.
Syntax:
if (condition)
statement;
else if (condition)
statement;
.
.
else
statement;
Flow Diagram of if-else-if ladder statement
Switch case
The switch case statement is used when we have multiple options and we need different task for each option.
Syntax:
switch (variable or an integer expression)
{
case constant:
//C Statements
;
case constant:
//C Statements
;
default:
//C Statements
;
}
Switch case
Rules for switch statement:
 An expression must always execute to a result.
 Case labels must be constants and unique.
 Case labels must end with a colon ( : ).
 A break keyword must be present in each case.
 There can be only one default label.
 We can nest multiple switch statements.

Decision control structures

  • 1.
  • 2.
    Decision Making C hasthree major decision making instructions—the if statement, the if-else statement, and the switch statement.  The decision control statements are the decision making statements that decides the order of execution of statements based on the conditions. if if-else else-if nested if else switch case statment
  • 3.
    Introduction Conditional Statements areUsed to Execute a set of Statements On some Conditions. It provides a unit of Block In which we can Either one statement or more than one statements. if the given condition is true then the set of statements are executed otherwise body is skipped.
  • 4.
    If Conditions If isconditional statement, which is used to execute a set of statement on some conditions. The condition must be of Boolean type expression. An expression, which returns only two value either True or False is known as Boolean type expression. Syntax: if (condition) { //Block of C statements here //These statements will only execute if the condition is true }
  • 5.
    Flow Diagram ofif statement
  • 6.
    If Else Condition Itis known as double blocked conditional statements.It means,it has True Parts as well as False part. If the given condition is true then the true part is executed otherwise flase part is executed. Synstax: if(condition) { // Statements inside body of if } else { //Statements inside body of else }
  • 7.
    Flow Diagram ofif else statement
  • 8.
    nested-if Using of oneif statement within another if statement is know as nested of if else statement. Syntax: if (condition1) { // Executes when condition1 is true if (condition2) { // Executes when condition2 is true } }
  • 9.
    Flow Diagram ofnested-if statement
  • 10.
    if-else-if ladder  Auser can decide among multiple options.  The C if statements are executed from the top down.  As soon as one of the conditions controlling the if is true,  the statement associated with that if is executed, and the rest of the C else-if ladder is bypassed.  If none of the conditions are true, then the final else statement will be executed. Syntax: if (condition) statement; else if (condition) statement; . . else statement;
  • 11.
    Flow Diagram ofif-else-if ladder statement
  • 12.
    Switch case The switchcase statement is used when we have multiple options and we need different task for each option. Syntax: switch (variable or an integer expression) { case constant: //C Statements ; case constant: //C Statements ; default: //C Statements ; }
  • 13.
  • 14.
    Rules for switchstatement:  An expression must always execute to a result.  Case labels must be constants and unique.  Case labels must end with a colon ( : ).  A break keyword must be present in each case.  There can be only one default label.  We can nest multiple switch statements.