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
StatementSyntax
If statementif(condition) Statement;
If-else statementIf (condition)
 {
 Statement 1;
 Statement 2;
 }
 else
 {
 Statement 3;
 Statement 4;
 }
Nested if-else statementIf (condition)
 {
 Statement 1;
 Statement 2;
 }
 Else if (condition)
 {
 Statement 3;
 Statement 4;
 }
 Else
 {
 Statement 5;
 Statement 6;
 }
Break statementBreak;
Continue statementContinue;
Goto statementgoto label;
Switch() statementSwitch (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
StatementSyntax
For loopFor(initialize counter; test condition; re-evaluation parameter)

{

Statement;

Statement;

}

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

{

Statement;

Statement;

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

Statement;

Statement;

}

}

While loopWhile (test condition)

{

Body of the loop

}

Do while loopdo

{

Statement;

}

While(condition);

Do-while with while loopDo while(condition)

{

Statement;

}

While (condition);

Related Posts

Leave a Comment