Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

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

View 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

View 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

View 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

View 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

View 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

View 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

View Answer

Answer: d [Reason:] None.