C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - General Questions (Q.No. 2)
2.
What is the similarity between a structure, union and enumeration?
Discussion:
50 comments Page 1 of 5.
Nagalaxmi Madari said:
1 month ago
Structures, unions and enums are user-defined data types which are used to create new data types.
Structure is a user-defined data type which contains variables of different data types, in structures, memory is allocated to individual variables, which are declared in the structure based on their data type.
Memory shares among the variables which are declared in the structure.
We can access any variable at a time.
The size of the structure is defined as the sum of the sizes of all members which are declared in the structure.
Unions are similar to structures, but in unions, the memory is allocated to all the variables with a maximum size of a data member, which is declared in the union.
Same /single memory shares among all the data members which are declared in the union.
We can only have one data member or variable at a time.
Unions are faster than structures and require less memory than structures.
Enum is user user-defined data type in which assigns integer constants to names for easy reading.
Structure is a user-defined data type which contains variables of different data types, in structures, memory is allocated to individual variables, which are declared in the structure based on their data type.
Memory shares among the variables which are declared in the structure.
We can access any variable at a time.
The size of the structure is defined as the sum of the sizes of all members which are declared in the structure.
Unions are similar to structures, but in unions, the memory is allocated to all the variables with a maximum size of a data member, which is declared in the union.
Same /single memory shares among all the data members which are declared in the union.
We can only have one data member or variable at a time.
Unions are faster than structures and require less memory than structures.
Enum is user user-defined data type in which assigns integer constants to names for easy reading.
Keerthana said:
7 years ago
All are user-defined datatypes which allow the user to create their own datatype which can be a combination of int, float, char, etc.
(7)
Bhushan shriram said:
8 years ago
Please, explain about union?
(3)
Rekha said:
8 years ago
Which is better to use structure or union? Any one explain in detail.
(2)
Vishu said:
9 years ago
@Kamal.
Linked list: list is a collection of elements. There are 2 ways of maintaining list in computer memory. The first way is to take an array for sorting elements of the list. But arrays have some disadvantage. Insertion and deletion of the element require more processing. The second way is implementing a list in a memory by using a self-referential structure.
Linked list: list is a collection of elements. There are 2 ways of maintaining list in computer memory. The first way is to take an array for sorting elements of the list. But arrays have some disadvantage. Insertion and deletion of the element require more processing. The second way is implementing a list in a memory by using a self-referential structure.
Neelima said:
9 years ago
Do the outputs for structure & union is same?
Sonali Adhav said:
10 years ago
Array.
Pointer.
Structure.
Union.
Enum.
Are the user defined or secondary types of data type in C?
Pointer.
Structure.
Union.
Enum.
Are the user defined or secondary types of data type in C?
(2)
Pallavi said:
10 years ago
Structure mean collection of multiple element that can be of different data types. Definition of union is same of structure but only data element is stored in union variable.
Sarath said:
10 years ago
Because the secondary data types are arrays, pointers, structures, union and enum, they are user defined data types All of them let you define new data types.
Lokija said:
10 years ago
I can't understand explain clearly.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers