1 While Loop
2 Do While Loop
3 For Loop
while Loop This is used to execute the block of statements till the value of the conditional expression is true .While loop if is true then the body of the loop is executed .After execution of the body (contain statements and increment /decrement par) the test condition is again tested and if it is true then the body is executed again .
Syntax :
while(expression)
{
statement 1;
increment /Decrement ;
}
do while it can execute the statement first and check the condition after . statement will execute once even if the expression is false .condition is checked at the end of the do while loop.
Syntax
do
{
statement ;
increment/decrement;
}
while (condition);
for loop for loop is used to initialize ,testing and increment/decrement into single line .this is fast and simple loop .
Syntax .for (variable initialize;testing;increment /decrement)
Nested Loop Nested Loop inside the another loop..
Syntax
for (variable initialize;testing;increment /decrement)
{
for (variable initialize;testing;increment /decrement)
{
statements;
}
}
Branching Statement There are many other control statements that can change the execution of loop or execution of the programe .These are given below
break ---these are used to exit from the loop or exit from the switch case
continue--the continue statement is used to skip the remaining statement of the body of the loop.it does not terminate the loop but transfer the control to start of the next loop iteration.
goto .it can jump the control to desier location











0 comments:
Post a Comment