ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

LANGUAGE C

Jump Statement

     C has four statements that perform an unconditional move (transfer of control from the point where it is, to a specified statement").

[1] return
[2I goto
[3] break
[4] continue

     return and goto can be used anywhere in the program, where break and continue statements are used in conjunction with any of the loop statements.

  The return Statement

     It is used to return from a function. It causes execution to return to the point at which the call to the function was made. The return statement can have a value with it, which it returns to the program from which the function was called.

  The goto Statement

     A goto statements in a program make it difficult to read. They reduce program reliability and make program difficult to maintain. A goto statement transfers control to any other statements within the same function in a C program, but it allows jumps in and out of blocks. 

#include <stdio.h>
main ( )
{
char ch; clrscr ( ) ;
printf("\nEnter a lower cased alphabet (a - z) : ") ;
scanf("%c", &ch);
if (ch < ' a' I I ch > ' z' ) 
{
      printf("\nCharacter not a lower cased alphabet");
else 
      switch (ch)
      {
        case 'a' :
        case 'e' : 
        case 'i'  :
        case 'o' : 
        case 'u' :
        printf("\nCharacter is a vowel" ); 
         break;
case 'z' :
       printf("\nLast Alphabet (z) was input"); 
       break;
default :
       printf("\nCharacter is a consonant");
       break;
}
}

  The break Statement

     The break statement has two uses. It can be used to terminate a case in the switch statement and/or to force immediate termination of a loop. When a break statement is encountered inside a loop, the loop is immediately terminated and the program control passes to the statement following the loop.it also causes exit from inner loop.

  The continue Statement

     The continue statement causes the next iteration of the enclosing loop to begin. When this statement is encountered in the program, the remaining statements in the body of the loop are skipped and the control is passed to the re-initialization.

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here