CONTROL STATEMENT

While Statement: It first evaluate the expression. if evaluates to non zero, then statement is executed and expression is reevaluated. it will continue until expression becomes false. In while statement condition is first tested, so that sometimes statement may not executed even in first time. The syntax of while statement is as following:

while (condition)

{

body of the loop

}

Do..While Loop : In do…while as long as the value of test condition is true (non-zero) set of statement is repeated again and again. The syntax of do…while loop is as following:

do

{

body of the loop

}

while(test condition)

For Loop : It consists of three expressions. First is used to initialize the index value, second expression is used to check whether or not loop is to be continue again and third one is used to change the index value for further change. The syntax of for loop is as following:

For (initialization; test-condition; increment)

{

body of the loop

}

Switch Statement : The switch statement is useful in case where a group of option are available and we have choose a particular statement. In the switch statement selection is based on the current value of an expression which is included in the switch statement . The syntax of the switch statement is as following:

Switch (integer expression)

{

case constant : statement

case constant : statement

……. …………………..

…… …………………..

…… …………………..

default : statement

}

Break statement : it is used to break loop or exit from the switch statement. Break statement is also can be used with in while, do-while, for and switch statement. the syntax of switch statement is as following:

break;

(without any embedded expression or statement)

Continue statement : It is used to bypass the remainder of the current pass through a loop. loop does not terminate when a continue statement is encountered. It can be included within a while, do-while, for statement. The syntax of continue statement is as following:

continue:

(without any embedded expression or statement)

Goto statement : This statement is used to alter the normal sequence of program execution by transferring control to some other part of the program. The syntax of goto statement is as following:

goto label;

Here a ‘label’ is an identifier used to label the target statement to which control will be transferred.