C MCQ set number 00681

1. What is the output of this C code?

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

a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error

Answer

Answer: d [Reason:] None.

2. What is the output of this C code?

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

a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error

Answer

Answer: d [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         do
  6.         {
  7.             i++;
  8.             if (i == 2)
  9.                 continue;
  10.                 printf("In while loop ");
  11.         } while (i < 2);
  12.         printf("%dn", i);
  13.     }

a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop

Answer

Answer: a [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         for (i; i < 2; i++){
  6.             for (j = 0; j < 3; j++){
  7.                 printf("1n");
  8.                 break;
  9.             }
  10.             printf("2n");
  11.         }
  12.         printf("after loopn");
  13.     }

a) 1
    2
    after loop
b) 1
    after loop
c) 1
    2
    1
    2
    after loop
d) 1
    1
    2
    after loop

Answer

Answer: c [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         while (i < 2)
  6.         {
  7.             if (i == 1)
  8.                 break;
  9.                 i++;
  10.                 if (i == 1)
  11.                     continue;
  12.                     printf("In while loopn");
  13.         }
  14.         printf("After loopn");
  15.     }

a) In while loop
    After loop
b) After loop
c) In while loop
    In while loop
    After loop
d) In while loop

Answer

Answer: b [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         char c = 'a';
  6.         while (i < 2){
  7.             i++;
  8.             switch (c) {
  9.             case 'a':
  10.                 printf("%c ", c);
  11.                 break;
  12.                 break;
  13.             }
  14.         }
  15.         printf("after loopn");
  16.     }

a) a after loop
b) a a after loop
c) after loop
d) None of the mentioned

Answer

Answer: b [Reason:] None.

7. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         printf("before continue ");
  5.         continue;
  6.         printf("after continuen");
  7.     }

a) Before continue after continue
b) Before continue
c) After continue
d) Compile time error

Answer

Answer: d [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.