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?
All of them let you define new values
All of them let you define new data types
All of them let you define new pointers
All of them let you define new structures
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
50 comments Page 5 of 5.

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.

Jithin james said:   1 decade ago
Can anyone explain more about Enum....plz

Reshmi Singh said:   1 decade ago
Nice explanation raju. Enum is basically used for storing different datatypes variables. It is follow indexes like{0, 1, 2, . }.

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.

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.

Prem said:   1 decade ago
I think structure, union and enum - user defined data type.

Ravendra Patel said:   1 decade ago
The working of structure and union is the same but the difference is in their memory allocation. The size of an structure is the summation of his all the member's size while the size of a union is the same as his largest member's size.

Anu said:   1 decade ago
Difference between structure and union is that......

Structure
structure allocates individual memory to all the variables declared in the structure based on there data types

whereas.....

unions allocation the memory takes place based on the variable which occupies largest memory space based on there data type

for example

if in a union 2 variables with data types char and int are given then it allocates a memory of 4 byte in GCC since it occupies more space than char the same memory is shared for both of them

Priya said:   1 decade ago
Can any one explain differnce between struct and enum ?

Swapnil said:   1 decade ago
@Priya: In structure only collection of different type of variables which are binded in one unit but enum are they who allows us to assign a particular value from given set to variable.

ex:
enum days {MON=-1, TUE, WED, THU, FRI, SAT};

//This allows days to have val from MON,TUE, WED,THU,FRI,SAT
Whose vaule are from -1 to 4. As MON=-1,TUE=0.


Post your comments here:

Your comments will be displayed after verification.