Some another Keyword’s

Some another Keyword’s (OR statements) which are Useful:-
1.      Break statement:-
The break statement is used to terminate execution of a particular set of statements and transfer the control to a point outside the current loop in the program. The break statement can be used in a switch statement, in a for loop or while loop.

2.      Goto statement:-
Goto statement is used to branch unconditionally from one point to another in a program. Commonly the goto statement is not used in C language but its use is sometimes desirable. The goto statement requires a label in order to identify the place where is has to branch. The label can be placed anywhere in the program.

Label: - A label is any valid variable name. Label is required when we use a goto statement to place the control of the program. The label can be placed anywhere in the program. A colon must follow a label.
E.g.
void main()
{
       float x,y;
       here :
       scanf(“%f”,&x);
       if(x<0)
           goto here;
       y=sqrt(x);
       printf(“the square root of %f %f \n”,x,y);
       goto here;
}

3.      Continue statement:-
The continue statement causes the loop to be continued with the next iteration after skipping all the statements in between the continue and the end of the loop. This statement can be used in any of the control structures.

0 comments:

Post a Comment