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.     struct p
  3.     {
  4.         char x : 2;
  5.         int y : 2;
  6.     };
  7.     int main()
  8.     {
  9.         struct p p;
  10.         p.x = 2;
  11.         p.y = 1;
  12.         p.x = p.x & p.y;
  13.         printf("%dn", p.x);
  14.     }

a) 0
b) Compile time error
c) Undefined behaviour
d) Depends on the standard

View Answer

Answer: a [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union u
  3.     {
  4.         struct p
  5.         {
  6.             unsigned char x : 2;
  7.             unsigned int y : 2;
  8.         };
  9.         int x;
  10.     };
  11.     int main()
  12.     {
  13.         union u u;
  14.         u.p.x = 2;
  15.         printf("%dn", u.p.x);
  16.     }

a) Compile time error
b) Undefined behaviour
c) Depends on the standard
d) 2

View Answer

Answer: a [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union u
  3.     {
  4.         struct
  5.         {
  6.             unsigned char x : 2;
  7.             unsigned int y : 2;
  8.         }p;
  9.         int x;
  10.     };
  11.     int main()
  12.     {
  13.         union u u;
  14.         u.p.x = 2;
  15.         printf("%dn", u.p.x);
  16.     }

a) Compile time error
b) 2
c) Undefined behaviour
d) Depends on the standard

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union u
  3.     {
  4.         struct
  5.         {
  6.             unsigned char x : 2;
  7.             unsigned int y : 2;
  8.         }p;
  9.         int x;
  10.     };
  11.     int main()
  12.     {
  13.         union u u.p.x = 2;
  14.         printf("%dn", u.p.x);
  15.     }

a) Compile time error
b) 2
c) Depends on the compiler
d) Depends on the standard

View Answer

Answer: a [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union u
  3.     {
  4.         struct
  5.         {
  6.             unsigned char x : 2;
  7.             unsigned int y : 2;
  8.         }p;
  9.         int x;
  10.     };
  11.     int main()
  12.     {
  13.         union u u = {2};
  14.         printf("%dn", u.p.x);
  15.     }

a) Compile time error
b) 2
c) Depends on the standard
d) None of the mentioned

View Answer

Answer: b [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     union u
  3.     {
  4.         struct
  5.         {
  6.             unsigned char x : 2;
  7.             unsigned int y : 2;
  8.         }p;
  9.         int x;
  10.     };
  11.     int main()
  12.     {
  13.         union u u.p = {2};
  14.         printf("%dn", u.p.x);
  15.     }

a) Compile time error
b) 2
c) Undefined behaviour
d) None of the mentioned

View Answer

Answer: a [Reason:] None.

7. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         unsigned int x : 2;
  5.         unsigned int y : 2;
  6.     };
  7.     int main()
  8.     {
  9.         struct p p;
  10.         p.x = 3;
  11.         p.y = 1;
  12.         printf("%dn", sizeof(p));
  13.     }

a) Compile time error
b) Depends on the compiler
c) 2
d) 4

View Answer

Answer: d [Reason:] None.

8. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         unsigned int x : 2;
  5.         unsigned int y : 2;
  6.     };
  7.     int main()
  8.     {
  9.         struct p p;
  10.         p.x = 3;
  11.         p.y = 4;
  12.         printf("%dn", p.y);
  13.     }

a) 0
b) 4
c) Depends on the compiler
d) 2

View Answer

Answer: a [Reason:] None.

9. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         unsigned int x : 7;
  5.         unsigned int y : 2;
  6.     };
  7.     int main()
  8.     {
  9.         struct p p;
  10.         p.x = 110;
  11.         p.y = 2;
  12.         printf("%dn", p.x);
  13.     }

a) Compile time error
b) 110
c) Depends on the standard
d) None of the mentioned

View Answer

Answer: b [Reason:] None.

10. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         unsigned int x : 1;
  5.         unsigned int y : 1;
  6.     };
  7.     int main()
  8.     {
  9.         struct p p;
  10.         p.x = 1;
  11.         p.y = 2;
  12.         printf("%dn", p.y);
  13.     }

a) 1
b) 2
c) 0
d) Depends on the compiler

View Answer

Answer: c [Reason:] None.

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