Decision Control Statements in C Language

by Emma

Decision Control Statements in C Language

The Decision statement checks the given condition and then executes its sub block. The decision statement determines the statement to be executed after True or False of a given condition.

Types if decision statement:

  1. If statement
  2. If-else statement
  3. Nested if-else statement
  4. Break statement
  5. Continue statement
  6. Goto statement
  7. Switch() statement
  8. Nested switch ()case
  9. Switch() case and Nested if
Statement Syntax
If statement if(condition) Statement;
If-else statement If (condition)
  {
  Statement 1;
  Statement 2;
  }
  else
  {
  Statement 3;
  Statement 4;
  }
Nested if-else statement If (condition)
  {
  Statement 1;
  Statement 2;
  }
  Else if (condition)
  {
  Statement 3;
  Statement 4;
  }
  Else
  {
  Statement 5;
  Statement 6;
  }
Break statement Break;
Continue statement Continue;
Goto statement goto label;
Switch() statement Switch (variable or expression)
  {
  Case constant A:
  Statement;
  Break;
  Case constant B:
  Statement;
  Break;
  Default:
  Statement;
  }

LOOP CONTROL STATEMENTS

The loop control statements in C are used to perform looping operations until the given condition is true. Once the condition is false, the control loop exits the statement.

Types

  1. For loop
  2. Nested for loops
  3. While loop
  4. do while loop
  5. do-while statement with while loop
Statement Syntax
For loop For(initialize counter; test condition; re-evaluation parameter)

{

Statement;

Statement;

}

Nested for loop for(initialize counter; test condition; re-evaluation parameter)

{

Statement;

Statement;

for (initialize counter; test condition; re-evaluation parameter)

Statement;

Statement;

}

}

While loop While (test condition)

{

Body of the loop

}

Do while loop do

{

Statement;

}

While(condition);

Do-while with while loop Do while(condition)

{

Statement;

}

While (condition);

Related Posts

Leave a Comment