Popular Posts

Saturday, July 19, 2008

CONTROL STRUCTURES

CONTROL STRUCTURES:

Three types of control structures:

1.Decision control structure : if,if else,nested if etc
2.Loop control structure : while loop,do..while loop, for loop,break statement,continue statement.
3.case control structure : switch,goto

1.Decision control structure:
ex: if(condition)
{
block of statements;
}
ex: if(condition)
{
block of statements;
}
else{ block of statements;}
ex: if(condition)//NESTED IF
{
if(condition1)
block of statements;
else
block statements;
}
2.Loop control structure:
ex: while(condition)
{
block statements;
}
ex: do
{
block statements;
}while(condition);
ex: for(initalization;condition;increment/decrement)//ex: for(i=0;i<=10;i++/i--)
{
block statements;
}
3.Case control structure:
ex: switch(condition)
{
case 1: statements;break;
case 2:statements;break;
default:statements;break;
}

No comments:

Post a Comment