C Programming Multiple Choice Question - Structure And Union
This section focuses on the "Structure And Union" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which of the following are themselves a collection of different data types?
Explanation: A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
2.Which operator connects the structure name to its member name?
3. Which of the following cannot be a structure member?
4. What is the correct syntax to declare a function foo() which receives an array of structure in function?
5. Union differs from structure in the following way
Explanation: When a variable is associated with a structure, the compiler allocates the memory for each member. The size of structure is greater than or equal to the sum of sizes of its members. The smaller members may end with unused slack bytes. While in case of Union when a variable is associated with a union, the compiler allocates the memory by considering the size of the largest memory. So, size of union is equal to the size of largest member.
6. The size of the following union, where an int occupies 4 bytes of memory is
Explanation: Largest size among the three structure variable is selected that is char z.
7. Members of a union are accessed as________________.
It is not possible to create an array of pointer to structures.
Explanation:Making sure of the length has nothing to do with whether you assign or copy. You cannot assign to an array in C, ever. The language doesn't allow it.
9. Which of the following statement is True?
Explanation: User has a control over the size of enumeration variable
size of union is size of the longest element in the union
Explanation:Max size of the union is the size of the largest data type or the memory taken by largest member.
Also check :