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.
Keerthana said:
8 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:
9 years ago
Which is better to use structure or union? Any one explain in detail.
(2)
Sonali Adhav said:
1 decade 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)
Knp said:
1 decade ago
In short structures are used to share different memory locations for variable and union is used to allocate large memory for all variables.
(1)
Nagalaxmi Madari said:
11 months 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.
(1)
Nithya said:
1 decade ago
These are the user defined data types. But enumeration only allocate in integer data types. Then how does is allocated for new data types for others?
(1)
Nagarjun said:
2 decades ago
S.I agree vtt the Lips .but Enumrated gives the different states of a variable
example;
Enum person
{
male,fmale;
}
where the person having 2 states male r female;
example;
Enum person
{
male,fmale;
}
where the person having 2 states male r female;
(1)
Jiten said:
1 decade ago
Structure are user define data types in which you can store more than one data type variable. It is similar to union. But in union you can access only one value at a time because in union memory allocated to only one member at a time. While in structure all of its member have its own memory. That's why structure is taking more memory then union.
Mahesh said:
1 decade ago
Hi, what is an array?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers