C Structure, Union, Enums Test 11) What is the similarity between a structure, union and enumeration?
The correct option is (a). Explanation: A structure, enumeration and union all of them can be helpful in defining a new data types in C language. It is used for creating new data types that holds all kinds of data type like int, char, float, array inside a user defined data type. So user can use new values and logic of operation in simple manner. 2) How will we free the allocated memory in a C program?
The correct option is (d). Explanation: The built in function free(var-name) is used for free or clear the memory space. If we use free() the referred memory location can be released for the future use or other operations. Therefore the free(var-name) is used for clear the allocated memory in a C program. 3) A union can be nested in a structure.
The correct option is (a). Explanation: In address mapping or allocation of structure, the program takes union as a one data type in it. Therefore union can be nested in a structure statement is true. 4) What will be the output of the below program?
The correct option is (b). Explanation: The union variable share the common memory for all its elements 'a' gets 'A' whose ASCII value is 65. The statement printf("%d", var.a); is used for printing the value 65 in output. Therefore the output of the program is 65. 5) The elements of union and structure are always accessed using & operator.
The correct option is (b). Explanation: No, because the elements of union and structure are always accessed using dot(.) operator.
Next TopicC Structure, Union, Enums 2
|