250+ TOP MCQs on Basics of Structures and Answers

C helps anyone preparing for Juniper Networks and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Juniper interviews on C Programming language.

Here is a listing of C multiple choice questions on “Basics of Structures” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  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: b
Clarification: None.

2. How many bytes in memory taken by the following C structure?

  1.     #include 
  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: a
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  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: a
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  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: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  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: b
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  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: b
Clarification: None.

7. What will be the output of the following C code according to C99 standard?

  1.     #include 
  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: a
Clarification: None.

8. What will be the output of the following C code according to C99 standard?

  1.     #include 
  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: b
Clarification: None.

9. What will be the output of the following C code according to C99 standard?

  1.     #include 
  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: a
Clarification: None.

Leave a Reply

Your email address will not be published. Required fields are marked *