Header Ads Widget

The goto Keyword in C Programming

 The goto statement is an unconditional jump statement that transfers the flow of control to another part of program. 

 
Whenever goto label; is encountered, the control is transferred  to the statement that is immediately after that label. 

#include <stdio.h>
int main( )
{
 int n;
 printf("Enter Number :");
 scanf("%d",&n);
 if(n%2 == 0)
     goto even;
 else
     goto odd;
 even : printf("%d is even ", n);
            goto end;
 odd : printf("%d is odd ", n);
          goto end;
 end : printf("\n ");
 return 0;
}

Post a Comment

0 Comments