C Programming Questions and Answers on Basics of Structures for Freshers

1. Which of the following are themselves a collection of different data types?

a) string
b) structures
c) char
d) all of the mentioned
Answer: b
2. User-defined data type can be derived by___________

a) struct
b) enum
c) typedef
d) all of the mentioned
Answer: d
3. Which operator connects the structure name to its member name?

a) –
b) <- br="">c) .
d) Both <- .="" and="" br="">
Answer: c
4. Which of the following cannot be a structure member?

a) Another structure
b) Function
c) Array
d) None of the mentioned
Answer: b
5. Which of the following structure declaration will throw an error?

a) struct temp{}s;
    main(){}
b) struct temp{};
    struct temp s;
    main(){}
c) struct temp s;
    struct temp{};
    main(){}
d) None of the mentioned
Answer: d
6. What is the output of this C code?
  1.     #include 
  2.     struct student
  3.     {
  4.         int no;
  5.         char name[20];
  6.     }
  7.     void main()
  8.     {
  9.         struct student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }
a) Compile time error
b) Nothing
c) hello
d) Varies
Answer: a
7. What is the output of this C code?
  1.     #include 
  2.     struct student
  3.     {
  4.         int no = 5;
  5.         char name[20];
  6.     };
  7.     void main()
  8.     {
  9.         struct student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }
a) Nothing
b) Compile time error
c) hello
d) Varies
Answer: b
8. What is the output of this C code?
  1.     #include 
  2.     struct student
  3.     {
  4.         int no;
  5.         char name[20];
  6.     };
  7.     void main()
  8.     {
  9.         student s;
  10.         s.no = 8;
  11.         printf("hello");
  12.     }
a) Nothing
b) hello
c) Compile time error
d) Varies
Answer: c
9. What is the output of this 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.         s.no = 8;
  11.         printf("%d", s.no);
  12.     }
a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: d
10. Can the above code be compiled successfully?
  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("%f\n", x.f);
  12.     }
a) Yes
b) No
c) Depends on the standard
d) Depends on the platform
Answer: c
11. What is the output of this 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
12. Number of bytes in memory taken by the below structure is
  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
View AnswerAnswer: a

13. What is the output of this 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("%d\n", p.k);
  12.     }
a) Compile time error
b) 10
c) Undefined behaviour
d) Segmentation fault
Answer: a
.
14. What is the output of this 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 %d\n", p.k, p);
  12.     }
a) Compile time error
b) 10 10
c) Depends on the standard
d) Depends on the compiler
Answer: a
15. What is the output of this 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 %d\n", x.k, p);
  13.     }
a) Compile time error
b) 10 10
c) Depends on the standard
d) Depends on the compiler
Answer: b
16. What is the output of this 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 %d\n", x.f, p);
  13.     }
a) Compile time error
b) 0.000000 10
c) Somegarbage value 10
d) 0 10
Answer: b
17. What is the output of this 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("%f\n", x.f);
  12.     }
a) 3.000000
b) Compile time error
c) Undefined behaviour
d) 1.000000
Answer: a
18. What is the output of this 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
19. What is the output of this 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("%f\n", x.f);
  12.     }
a) 0.000000
b) Somegarbagevalue
c) Compile time error
d) None of the mentioned
Answer: a

Related

Computer Fundamentals Multiple choice Questions and Answers on The Arithmetic & Logic Unit for Freshers

1. The ‘heart’ of the processor which performs many different operations _____________ a) Arithmetic and logic unitb) Motherboardc) Control Unitd) Memory Answer: a Explanation: The Arithmetic and...

Multiple Choice Questions and Answers on Google Application Portfolio of Cloud Computing

1. Which of the following creates a custom search utility for a particular Web site ? a) Desktopb) Directoryc) Custom Searchd) None of the mentioned Answer: c Explanation: Custom Search lets you ...

Computer Fundamentals Multiple choice Questions and Answers on The Storage Unit for Freshers

1. Components that provide internal storage to the CPU are ______ a) Registersb) Program Countersc) Controllersd) Internal chips Answer: a Explanation: The Registers are the fast storage units. T...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item