69 - DIFFERENCE BETWEEN STRUCTURE & UNION - C PROGRAMMING
ฝัง
- เผยแพร่เมื่อ 5 พ.ย. 2017
- Difference between union and structure is in memory allocated to the variable.
For structure variable the memory allocated is the sum of sizes of all the members of a structure.
For Union variable the memory allocated is the highest size of the member of a union.
Excellent explaination sir ...👏👏
Sir in the example which you gave for unions, will the union can only save one element at a time or can it save both the elements?
Thank you so much sir .. Cleared my confusion
Sir,what happens if we declare the float first in union and then int ?will the output somehow change?
Great explained 😍
Explained it with a great conceptual clarity sir.
Awesome explanation
You r the best sir
Sir in the previous video about structures u said that if we give a tag name to the structure we have declare structure variable in the main function but in this program why u have declared before main function but u have given tag name student does it matter or not please explain sir?
Nice explanation 👌
Sir for union the output will print only the higher value?
Thnks, so far clear and easiest explanation
tell me in which type of condition where union can be use. and why use union. why not structure
very nicely explained.
Thankyouuu
Sir I need the difference between static memory and dynamic allocation can you send the link
Thanku sir very briefly explained
Sir we want clarifies structure, function, pointer, files chapter some clarification in that programme not understand if you want to explain
Thankyou sir ❤
By u r lecturer I will get good marks sir conform pakka
Clear explaination thank u sir
No douts sir very t q sir
Very simple He made understand
sir for float it is coming 0.0000
what should i do
Thank you very much sir
Thanks
Tq sir
Tq
How to use unions to arrays
That was good u deserve a like and subscribe!!
Sir if both data types have same size then how the memory is allocated and what will be the output
hi Praneeth
if both the members are of same data type like
struct
{
int a;
int b;
}s1;
Here S1 is structure variable with two members with integer data type so Memory allocated for S1 is 4 Bytes.
union
{
int a;
int b;
}s1;
Here S1 is union variable with two members with integer data type so Memory allocated for S1 is 2 Bytes and the same 2 Bytes will be shared by both the union members.
Hope your doubt has been clarified.
it will take one of them
Good sir
Then what is the use of union sir
Super sir
super sir
In the union program I get as output the first member of the union variable s1, and not the highest is shared, i.e rno = 20 perc = 0.00000
May I have an answer?
its u.i not s use u.i for union u will get the answer
Same for me
So are unions used to save memory ?
yes
Sir how to a declare function
Nice
thank u sir
hi manoj
i would like to have a FEEDBACK ( in the form of video not more than 15 sec) from you towards our channel and my sessions.so that i will collect feedbacks from all and will upload in youtube,
Send your valuable FEEDBACK to my WhatsApp number : +91 9885466061 (91 is the country code)
waiting for your valuable feedback.
th-cam.com/users/sundeepsaradhi
SO MAKE A VIDEO WITH FEEDBACK ON OUR CHANNEL AND SEND AS SOON AS POSSIBLE.
Sir ,then how to print rno value in union ?
Just dont print tha percentage
Sir, please upload videos on files, type definition ,dynamic memory location ,preprocessor directives,sir, please.....
hi vardini
i would like to have a FEEDBACK ( in the form of video not more than 15 sec) from you towards our channel and my sessions.so that i will collect feedbacks from all and will upload in youtube,
Send your valuable FEEDBACK to my WhatsApp number : +91 9885466061 (91 is the country code)
waiting for your valuable feedback.
th-cam.com/users/sundeepsaradhi
SO MAKE A VIDEO WITH FEEDBACK ON OUR CHANNEL AND SEND AS SOON AS POSSIBLE.ask your friends to send their feedback.
Yes sir
sir about merge and quick sort pls explain sir
HI manoj definitely i will upload them soon with in 2 or 3 days
sir, I'm geting worng out put
#include
union student{
int roll;
float mark;
}s1 = {10, 99.9};
main()
{
printf("Values of S1 : %d \t %f
", s1.roll, s1.mark);
}
output :
Values of S1 : 10 0.000000
whats the error ?
&
hi isnt int 4 byte?
yep
Ok bie
Tell use of union
I requested sir
Sir suppose we have char and int datatypes under union...
Now we store 10 into int and print%c, char...
What output we will get?
Does it gives 10?
This is why i hate byjus 😁
super sir
hi shiva
thanks for your interest towards our channel.