1.

Do the difference between structure and unistructures solution for 2marks​

Answer»

Answer:

Structure and union both are user defined data TYPES which contains variables of different data types. Both of them have same syntax for DEFINITION, declaration of variables and for accessing MEMBERS. Still there are many difference between structure and union. In this tutorial we will take a LOOK on those differences.

Difference between Structure and Union

Structure 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



Discussion

No Comment Found

Related InterviewSolutions