What is the difference between structures and union

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions

CE2302-STRUCTURAL-ANALYSIS-I--->View question


Asked On2017-06-05 08:52:24 by:Aparna-Dasgupta

Taged users:
arunwebber

Likes:
Be first to like this question

Dislikes:
Be first to dislike this question
Talk about this  Delete  Like  Dislike
View all qusetions

You might like this video:Difference between Hub, Switch and Router
Watch more here

Watch more videos from this user Here

Learn how to upload a video and start earning here

Answers

The difference between structure and union is,
1. The amount of memory required to store a structure variable is the sum of the size of all the members.
On the other hand, in case of unions, the amount of memory required is always equal to that required by its largest member.
2. In case of structure, each member have their own memory space but In union, one block is used by all the member of the union.


Answerd on:2017-06-13 Answerd By:tarun101

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this  Delete  Like  Dislike

You might like this video:Direct Memory Access
Watch more here

Watch more videos from this user Here

Learn how to upload a video over here

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 share the same memory space. This is the biggest difference between structure and union.

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

In above example variable marks is of float type and have largest size (4 bytes). So the total memory required to store union variable s1 is 4 bytes.


Answerd on:2019-06-18 Answerd By:avi738

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this  Delete  Like  Dislike

You might like this video:East India Company
Watch more here

Watch more videos from this user Here

Learn how to upload a video and start earning here



Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.
Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question
Career: Work or do your internship with us.Work with us
Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder