C Programming - C Structures And Unions Questions and Answers

C Programming : C Structures And Unions

In the C language structures are used to group together different types of variables under the same name. Following question bank related to the MCQ questions about C structures and unions

1. What is the output of following C code?
main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e ={"Tiger"}
printf("%d%d%f",e.age,e.sal);
}
[A] Error
[B] Garbage Collection
[C] 0 0.000000
[D] 1 0.000000

Answer: C. 0 0.000000

2. Which of the following comment about the usage of structures in true?
[A] Storage class can be assigned to individual member
[B] Individual members can be initialized within a structure type declaration
[C] The scope of the member name is confined to the particular structure, within which it is defined
[D] None of above

Answer: C. The scope of the member name is confined to the particular structure, within which it is defined

Explanation:

Structure is user defined data type which is used to store heterogeneous data under unique name.
3. Which of the following comment about Union is false?
[A] Union is a structure whose members share same memory area
[B] The compiler will keep track of what type of information is currently stored
[C] Only one of the members of union can be assigned a value at particular time
[D] Size allocated for Union is the size of its member needing the maximum storage

Answer: B. The compiler will keep track of what type of information is currently stored

Explanation:

Union is similar to structure the only difference is the way the memory allocated to structure and union
4. Which of the following is a collection of different data types?
[A] String
[B] Array
[C] Structure
[D] Files

Answer: C. Structure

Explanation:

Structure is a user defined data type which contains the variables of different data types.
5. For accessing a structure element using a pointer,you must use?
[A] Pointer operator (&)
[B] Dot operators(.)
[C] Pointer operator(*)
[D] Arrow operator(->)

Answer: D. Arrow operator(->)

Explanation:

For accessing the structure element using pointers arrow operator is used otherwise dot operator is used.
6. Which operator is used to connect structure name to its member name?
[A] dot operator(.)
[B] logical operator(&&)
[C] pointer operator(&)
[D] Arrow operator(->)

Answer: A. dot operator(.)

7. In C, structure values can be passed as arguments to function by?
[A] passing each member of the structure as an argument of function call
[B] passing copy of the entire structure to the called function
[C] passing structure as an argument using pointer
[D] All of above

Answer: D. All of above

8. A -> B is syntactically correct if?
[A] a and b are structure
[B] a is a structure and b is a pointer to structure
[C] a is a pointer to structure and b is a structure
[D] a is a pointer to structure in which b is a field

Answer: D. a is a pointer to structure in which b is a field

Are these questions helpful for you?


Comments: (Your feedback is valuable to us)

Mital Patel 7 months ago Reply

Its really userful.


sainath 1 year ago Reply

thank u so much


amit kumar saini 1 year ago Reply

nyc mcq
give more quize


kaviya 1 year ago Reply

thank u


Ram Khatkar 2 years ago Reply

Good Quize

Ankit verma 2 years ago

very Nice Quize.


Prafulla Vyas 2 years ago Reply

IT IS VERY INFORMATIVE