Goto statement in c language.

Goto statement-> 

                                   This statement  is used for transfer the control from one place to another place  in a program. Generally  it is not used in programs because it take more time to execute and difficult to understand and debugging in a program. 

■》 backward  jump->

#include<stdio.h>
#include<conio.h>
void main()
{
 // backward jump 
 int n=1;
 label:
     printf("%d ",n);
     n++;
     if(n<=10)
     goto label;
     getch();
 }
■》Output->

1 2 3 4 5 6 7 8 9 10

--------------------------------------------------------------------------
■》forward jump->


#include<stdio.h>
#include<conio.h>
void main()
{
 // forward jump
 printf("hello");
 goto label;
 printf("everyone");
 label: 
          printf(" ved ");
          getch();
}

■》Output->


    hello ved


Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.