“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
structure is abstract data type!
structures are used to represent data in user defined type.
each member of structure is allocated separate memory, for memory optimization memory padding is to be considered.
contrary in a union memory is not allocated to each member variable, instead to member which occupies highest amount of memory, the same memory is used among all the members.
the main difference b/w structure and union is occupying of size.
the size of the union is depending on the element which has largest size in that union.
where as the size of the structure is sum of all the elements sizes declared in that structure.
the application of structure is to represent different data items in a continuous memory block.
1. Structure is user defined data type, by means we can store different type of data.
2. The most important difference between structure and union is in the size. Size of structure is the size of all the elements withing the structure where as the size of union is the size of highest element within it.
the size of the union is depending on the element which has largest size in that union.
where as the size of the structure is sum of all the elements sizes declared in that structure
structure is abstract data type!
structures are used to represent data in user defined type.
each member of structure is allocated separate memory, for memory optimization memory padding is to be considered.
contrary in a union memory is not allocated to each member variable, instead to member which occupies highest amount of memory, the same memory is used among all the members.
the main difference b/w structure and union is occupying of size.
the size of the union is depending on the element which has largest size in that union.
where as the size of the structure is sum of all the elements sizes declared in that structure.
the application of structure is to represent different data items in a continuous memory block.
1. Structure is user defined data type, by means we can store different type of data.
2. The most important difference between structure and union is in the size. Size of structure is the size of all the elements withing the structure where as the size of union is the size of highest element within it.
the size of the union is depending on the element which has largest size in that union.
where as the size of the structure is sum of all the elements sizes declared in that structure
we can access only one union element at a time unlike structure
Leave an Answer/Comment