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.     const int a = 1,  b = 2;
  3.     int main()
  4.     {
  5.         int x = 1;
  6.         switch (x)
  7.         {
  8.         case a:
  9.             printf("yes ");
  10.         case b:
  11.             printf("non");
  12.             break;
  13.         }
  14.     }

a) yes no
b) yes
c) no
d) Compile time error

View Answer

Answer: d [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define max(a) a
  3.     int main()
  4.     {
  5.         int x = 1;
  6.         switch (x)
  7.         {
  8.         case max(2):
  9.             printf("yesn");
  10.         case max(1):
  11.             printf("non");
  12.             break;
  13.         }
  14.     }

a) yes no
b) yes
c) no
d) Compile time error

View Answer

Answer: c [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         switch (printf("Do"))
  5.         {
  6.         case 1:
  7.             printf("Firstn");
  8.             break;
  9.         case 2:
  10.             printf("Secondn");
  11.             break;
  12.         default:
  13.             printf("Defaultn");
  14.             break;
  15.         }
  16.     }

a) Do
b) DoFirst
c) DoSecond
d) DoDefault

View Answer

Answer: c [Reason:] None.

4. Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 1;
  5.         switch (a)
  6.         case 1:
  7.             printf("%d", a);
  8.         case 2:
  9.             printf("%d", a);
  10.         case 3:
  11.             printf("%d", a);
  12.         default:
  13.             printf("%d", a);
  14.     }

a) No error, output is 1111
b) No error, output is 1
c) Compile time error, no break statements
d) Compile time error, case label outside switch statement

View Answer

Answer: d [Reason:] None.

5. Switch statement accepts.
a) int
b) char
c) long
d) all of the mentioned

View Answer

Answer: d [Reason:] None.

6. Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 1;
  5.         switch (a)
  6.         {
  7.         case a:
  8.             printf("Case A ");
  9.         default:
  10.             printf("Default");
  11.         }
  12.     }

a) Output: Case A
b) Output: Default
c) Output: Case A Default
d) Compile time error

View Answer

Answer: d [Reason:] None.

7. Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     switch (ch)
  3.     {
  4.     case 'a':
  5.     case 'A':
  6.         printf("true");
  7.     }

a) if (ch == ‘a’ && ch == ‘A’) printf(“true”);
b) if (ch == ‘a’)
    if (ch == ‘a’) printf(“true”);
c) if (ch == ‘a’ || ch == ‘A’) printf(“true”);
d) none of the mentioned

View Answer

Answer: c [Reason:] None.

.woocommerce-message { background-color: #98C391 !important; }