Science, asked by Anonymous, 11 months ago

differentiate between structure and union?​

Answers

Answered by trunkscapsule999
0

Answer:

The structure and union both are the container data types that can hold data of any “type”. The one major difference that distinguishes structure and union is that the structure has a separate memory location for each of its members whereas, the members of a union share the same memory location

Answered by VinniSharma
1

Here's ur answer buddy!!

#Difference between Structure and Union :-

In structure each member get separate space in memory. Take below example.

struct student { int rollno; char gender; float marks; }s1;

The total memory required to store a structure variable is equal to the sum of size of all the members. In above case 7 bytes (2+1+4) will be required to store structure variable s1.

In union, the total memory space allocated is equal to the member with largest size. All other members share the same memory space. This is the biggest difference between structure and union.

union student { int rollno; char gender; float marks; }s1;

HOPE IT HELPS!!

Similar questions