DECISION CONTROL STATEMENTS IN C LANGUAGE | FULL INFORMATION

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 the True or False of a given condition.


Types of 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


Loop control statements in C are used to perform looping operations until the given condition is true. Once the condition is false the control comes out of the loop statement.


Types


  1. For loop
  2. Nested for loops
  3. While loop
  4. do-while loop
  5. do-while statement with the 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);



AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST