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 3 of 5.

Nups said:   1 decade ago
Please tell the proper difference between structure and enum and then union and enum?

Rj kumar said:   1 decade ago
Because these are user defined data type that use to define another data type.

Pooja said:   1 decade ago
Are structure & union just differ in tums of memory. Is there not any other difference.

Kamal said:   1 decade ago
What is linked list in programming on C?

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)

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)

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.

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

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

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.


Post your comments here:

Your comments will be displayed after verification.