C MCQ set number 00696

1. What is the output of this C code?

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

a) 5
b) Hey
c) 5 Hey
d) Nothing

Answer

Answer: c [Reason:] None.

2. goto can be used to jump from main to within a function
a) true
b) false
c) depends
d) varies

Answer

Answer: b [Reason:] None.

3. 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.    }

a) 1 4
b) Compile time error
c) 1 2 4
d) 1 3 4

Answer

Answer: a [Reason:] None.

4. 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("%dn", 3);
  8.     }

a) Compile time error
b) 1 2 3
c) 1 2
d) 1 3

Answer

Answer: b [Reason:] None.

5. 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.     }

a) 1 2 3
b) 1 3
c) 1 3 2
d) Compile time error

Answer

Answer: d [Reason:] None.

6. 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("loopn");
  11.                 goto l1;
  12.             }
  13.         }
  14.    }

a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop

Answer

Answer: d [Reason:] None.

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 (l1: i < 2)
  6.         {
  7.             i++;
  8.             while (j < 3)
  9.             {
  10.                 printf("loopn");
  11.                 goto l1;
  12.             }
  13.         }
  14.    }

a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop

Answer

Answer: b [Reason:] None.

8. 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("loopn");
  11.                     goto l1;
  12.                 }
  13.             }
  14.    }

a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop

Answer

Answer: a [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.