Log In Register

Units


Goto & Labels - Questions and Answers

 

Practice these Goto & Labels under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Goto & Labels for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Goto & Labels of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Goto & Labels.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Goto & Labels under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Goto & Labels topic of C Programming:

 

1.

The output of the code below is

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         if (i == 0)
  6.         {
  7.             goto label;
  8.         }
  9.         label: printf("Hello");
  10.     }

Answer: Option D

Explanation:

2.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         while (l1: i < 2)
  6.         {
  7.             i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("loop\n");
  11.                 goto l1;
  12.             }
  13.         }
  14.    }

Answer: Option D

Explanation:

3.

What is the output of the code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         l1: while (i < 2)
  6.         {
  7.             i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("loop\n");
  11.                 goto l1;
  12.             }
  13.         }
  14.     }

Answer: Option D

Explanation:

4.

What is output of code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         while (i < 2)
  6.         {
  7.             l1 : i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("Loop\n");
  11.                 goto l1;
  12.             }
  13.         }
  14.     }

Answer: Option B

Explanation:

5.

goto can be used to jump from main to within a function

Answer: Option C

Explanation:

6.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         goto l1;
  6.         printf("%d ", 2);
  7.         l1:goto l2;
  8.         printf("%d ", 3);
  9.         l2:printf("%d ", 4);
  10.    }

Answer: Option D

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         while (i < 2)
  6.         {
  7.             l1: i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("loop\n");
  11.                 goto l1;
  12.             }
  13.         }
  14.    }

Answer: Option C

Explanation:

8.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         goto l1;
  6.         printf("%d ", 2);
  7.     }
  8.     void foo()
  9.     {
  10.         l1: printf("3 ", 3);
  11.     }

Answer: Option A

Explanation:

9.

What is the output of the code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         goto l1;
  6.         printf("%d ", 2);
  7.         l1:goto l2;
  8.         printf("%d ", 3);
  9.         l2:printf("%d ", 4);
  10.    }

Answer: Option D

Explanation:

10.

What is the output of code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         while (l1: i < 2)
  6.         {
  7.             i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("loop\n");
  11.                 goto l1;
  12.             }
  13.         }
  14.     }

Answer: Option C

Explanation:

11.

The output of the code below is

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int i = 0, k;
  5.         label: printf("%d", i);
  6.         if (i == 0)
  7.             goto label;
  8.     }

Answer: Option C

Explanation:

12.

What is the output of code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         l1:l2:
  6.         printf("%d ", 2);
  7.         printf("%d\n", 3);
  8.     }

Answer: Option C

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         l1:l2:
  6.         printf("%d ", 2);
  7.         printf("%d\n", 3);
  8.     }

Answer: Option C

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         l1: while (i < 2)
  6.             {
  7.                 i++;
  8.                 while (j < 3)
  9.                 {
  10.                     printf("loop\n");
  11.                     goto l1;
  12.                 }
  13.             }
  14.    }

Answer: Option D

Explanation:

15.

What is the output of code given below?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("%d ", 1);
  5.         goto l1;
  6.         printf("%d ", 2);
  7.     }
  8.     void foo()
  9.     {
  10.         l1 : printf("3 ", 3);
  11.     }

Answer: Option A

Explanation: