Getting Started With C

Goto statements

Syntax:

    Syntax1        |   Syntax2 
    ----------------------------
     goto label;   |    label:  
    .              |    .
    .              |    .
    .              |    .
    label:         |    goto label;

   

Explanation:

sample code:

Program.c

output:

output.c

Resources :

Featured
Special title treatment

With supporting text below as a natural lead-in to additional content.

Q1. What will be the output of the following C code?

    #include 
                      int main()
                      {
                          printf("%d ", 1);
                          l1:l2:
                          printf("%d ", 2);
                          printf("%d\n", 3);
                      }
                  

Q2. What will be the output of the following C code?

    #include 
                      void main()
                      {
                          int i = 5, k;
                          if (i == 0)
                              goto label;
                              label: printf("%d", i);
                              printf("Hey");
                      }