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 2 of 5.
Urs Truely Naresh said:
1 decade ago
Structure occupies fixed width of memory space, while Union takes the required memory based on the values.
Enum has a set of value to choose from and it can be part of either the Struct/Union or stand-alone.
Enum has a set of value to choose from and it can be part of either the Struct/Union or stand-alone.
Senthil.J said:
1 decade ago
I agree with raju he have given a good explanation about these.
In short structures are used to share different memory locations for variable and union is used to allocate large memory for all variables.
In short structures are used to share different memory locations for variable and union is used to allocate large memory for all variables.
Runa said:
2 decades ago
Structures unions and enumeration is used to create a new datatyppe that holds all kinds of datatype that is it includesn a datatype that can hold int, float, char, array inside a user ndefined datatype.
Vinaysan said:
1 decade ago
I agree with runs. He/she said very nice defnition. And one more is the main difference between structure and union is
Structures allocates diffrent memory locations.
Union allocates large memory.
Structures allocates diffrent memory locations.
Union allocates large memory.
Lipsa said:
1 decade ago
I agree with the runa and the main difference is the structure allocate different memory location with the data types but union allocate one large memory location for their members.
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.
Ashish Moreshwar said:
1 decade ago
Question is the similarity between a structure, union and enumeration. I think These all are the user defined data type. That holds various types of other data types.
Rohit8421 said:
1 decade ago
I'm agree that structures and union are use to define new data type , but how enumeration is use to define new data type. it just internally store an integer value.
Nagarjun said:
1 decade 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)
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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers