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:
49 comments Page 1 of 5.
Keerthana said:
6 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.
(6)
Bhushan shriram said:
7 years ago
Please, explain about union?
(2)
Rekha said:
7 years ago
Which is better to use structure or union? Any one explain in detail.
(2)
Sonali Adhav said:
9 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)
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)
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)
Manmeet said:
9 years ago
Structures: Structure is denied as a collection of similar elements with different data types. The syntax of structure is :
struct book
{
int pages;
char name;
char author;
int edition;
}b;
Unions: It is a special data type which looks like a structure but are different from each other .
The syntax of union is :
union book
{
char name;
int pages;
int edition;
};
union book b;
The major difference between is there sizes.
In structures all the sizes of attributes are considered where as in case of unions only data type with max size is considered.
Enum: These are the special variables which can assume values which have been previously defined.
Syntax is:
enum month{jan=1, feb, march, april, may}.
enum month this_month;
This_month=feb;
struct book
{
int pages;
char name;
char author;
int edition;
}b;
Unions: It is a special data type which looks like a structure but are different from each other .
The syntax of union is :
union book
{
char name;
int pages;
int edition;
};
union book b;
The major difference between is there sizes.
In structures all the sizes of attributes are considered where as in case of unions only data type with max size is considered.
Enum: These are the special variables which can assume values which have been previously defined.
Syntax is:
enum month{jan=1, feb, march, april, may}.
enum month this_month;
This_month=feb;
Rj kumar said:
1 decade ago
Because these are user defined data type that use to define another data type.
Nups said:
1 decade ago
Please tell the proper difference between structure and enum and then union and enum?
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