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.
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?
Murty SVVSN said:
1 decade ago
An array holds a collection related data items that are all belongs to one particular data type, i.e a single name to all data items but the data items have different memory locations.
Ex. datatype array_name[size];
int array[5];
float a[10];
char a[5];
so on...
Ex. datatype array_name[size];
int array[5];
float a[10];
char a[5];
so on...
Vivek said:
1 decade ago
Because these are user defined data type and each one contain own different data type collection.
Alex said:
1 decade ago
Can any one give an example of enum that contains different type of data-types ?
Saravanakumar said:
1 decade ago
How to store multiple data types in array?
Pradeep kumar said:
1 decade ago
Use of structure we can use multiple data types in array.
We can define structure, union and enum.
STRUCTURE:
It is a user define data type that have we use define variable of different type of data type. it have allocate individual memory to all the variables declared in the structure based on there data types
UNION:
It is same as structure but memory allocation is maximum of there data type. In union variable have share these memory.
ENUM:
It have have declared different data type. the value of data type start with 0 by default.
Ex. enum={a,b,c,d};
Here initialize the value of
a=0
b=1
c=2
d=4
But enum={a=6,b,c,d}
Here initialize the value of
a=6
b=7
c=8
d=9
We can define structure, union and enum.
STRUCTURE:
It is a user define data type that have we use define variable of different type of data type. it have allocate individual memory to all the variables declared in the structure based on there data types
UNION:
It is same as structure but memory allocation is maximum of there data type. In union variable have share these memory.
ENUM:
It have have declared different data type. the value of data type start with 0 by default.
Ex. enum={a,b,c,d};
Here initialize the value of
a=0
b=1
c=2
d=4
But enum={a=6,b,c,d}
Here initialize the value of
a=6
b=7
c=8
d=9
Hemant said:
1 decade ago
Explain with program enum?
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.
Nagalaxmi Madari said:
1 month 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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers