Control Structure in C | Basic IT Topic

Control Structure in C

control structure

CONTROL STRUCTURE:-

Hanging if is not allowed in C language.

If a statement is used for checking range and yes/no problem.

else is the optional part of the if.

Execution of switch case starts from the match case.

Use break to prevent the falling of control from one case to another case.

If none of the cases are satisfied then default case will be satisfied.

Case character only can be integral constant.

Switch case only checks integral does not check the float.

Continue cannot be the part of the switch case.

Switch without case no use ( no output no error).

Duplicate case is not allowed in C.

Switch case is the replacement of if…else statement

Switch case is used for selection control statement

Loop counter can be int, char, and float

If loop counter is not initialized in a loop , that is called odd loop

Loop is an alternate of function recursion and function recursion is an alternate of loop.

for loop is suitable for finite loop, while loop is suitable for unknown loop and do while loop is suitable for at least once

loop counter has its own block scoping

Drop all the parts of for loop is an infinite loop but drops all part of while and do while loop is an error

break in loop transfer control outside the loop

continue  transfer the control to the beginning of the loop

If loop counter exceeds its range, it will be infinite loop

Every loop has start value, step value and stops value

If loop loses its step value, it will be an infinite loop

Repeating some parts of program and Software delay use loop

A loop is faster than function recursion.

 

Loop Control Structure:-

For

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

{

Statement;

Statement;

}

While

while(test condition)

{

Body of loop

}

 

Do-while

do

{

statement;

}

while(condition)

Selection Control Structure:-

Switch case

Switch(variable)

{

Case constant A;

Statement;

Break;

Case constant B;

Statement;

Break;

Default;

Statement;

}

Default

 

Decision Control Structure:-

If:-

if(condition)

Statement;

If Else

If (condition)

{

Statement 1;

Statement 2;

}

else

{

Statement 3;

Statement 4;

}

Break statement

Break;

Continue statement;

Continue;

Default;

Jump Control Structure:-

Go to

goto label;

basicittopic

basicittopic

A Computer Science Study for IT students and people of IT community