C MCQ set number 00716

1. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         struct student
  5.         {
  6.             int no;
  7.             char name[20];
  8.         };
  9.         struct student s;
  10.         no = 8;
  11.         printf("%d", no);
  12.     }

a) Nothing
b) Compile time error
c) Junk
d) 8

Answer

Answer: b [Reason:] None.

2. Number of bytes in memory taken by the below structure is

  1.     #include <stdio.h>
  2.     struct test
  3.     {
  4.         int k;
  5.         char c;
  6.     };

a) Multiple of integer size
b) integer size+character size
c) Depends on the platform
d) Multiple of word size

Answer

Answer: a [Reason:] None.

3. What is the output of this C code?

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

a) Compile time error
b) 10
c) Undefined behaviour
d) Segmentation fault

Answer

Answer: a [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     struct
  3.     {
  4.         int k;
  5.         char c;
  6.     } p;
  7.     int p = 10;
  8.     int main()
  9.     {
  10.         p.k = 10;
  11.         printf("%d %dn", p.k, p);
  12.     }

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

Answer

Answer: a [Reason:] None.

5. What is the output of this C code?

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

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

Answer

Answer: b [Reason:] None.

6. What is the output of this C code?

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

a) Compile time error
b) 0.000000 10
c) Somegarbage value 10
d) 0 10

Answer

Answer: b [Reason:] None.

7. What is the output of this C code(according to C99 standard)?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         int k;
  5.         char c;
  6.         float f;
  7.     };
  8.     int main()
  9.     {
  10.         struct p x = {.c = 97, .f = 3, .k = 1};
  11.         printf("%fn", x.f);
  12.     }

a) 3.000000
b) Compile time error
c) Undefined behaviour
d) 1.000000

Answer

Answer: a [Reason:] None.

8. What is the output of this C code(according to C99 standard)?

  1.  #include <stdio.h>
  2.     struct p
  3.     {
  4.         int k;
  5.         char c;
  6.         float f;
  7.     };
  8.     int main()
  9.     {
  10.         struct p x = {.c = 97, .k = 1, 3};
  11.         printf("%f n", x.f);
  12.     }

a) 3.000000
b) 0.000000
c) Compile time error
d) Undefined behaviour

Answer

Answer: b [Reason:] None.

9. What is the output of this C code(according to C99 standard)?

  1.     #include <stdio.h>
  2.     struct p
  3.     {
  4.         int k;
  5.         char c;
  6.         float f;
  7.     };
  8.     int main()
  9.     {
  10.         struct p x = {.c = 97};
  11.         printf("%fn", x.f);
  12.     }

a) 0.000000
b) Somegarbagevalue
c) Compile time error
d) None of the mentioned

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.