Monday, 23 October 2023

C PRO 33 : WAP to show the memory occupied by Structure and Union

 

// Program
struct S
{
char name[30];
int rollno;
float weight;
};
union U
{
char n[30];
int rno;
float w;
};
int main()
{
struct S obj1;
union U obj2;
printf("\nTotal Bytes taken by Structure : %d",sizeof(obj1));
printf("\nTotal Bytes taken by Union : %d",sizeof(obj2));
return 0;
}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.