Unions In C: C Tutorial In Hindi #39
HTML-код
- Опубликовано: 18 май 2019
- In this series of C programming tutorial videos, I have explained you everything you need to know about C language. I hope you are enjoying this C course in Hindi.
►This C Lecture is a part of this C Programming Course: • C Language Tutorials I...
►Source Code + Notes: codewithharry.com/videos/c-la...
►Click here to subscribe - / @codewithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Learn Python In Hindi ...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithharry.com
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here
For structure: 4+4+1=9
(int+float+char)
For union: max(4,4,1)=4
max(int,float,char)
well explained
@@klredits1790 Thank you
Good explained
U are right about union but for structure it will take 12 bytes instead of 9 byte because of structure padding
@@prashantkawathe933 what's structure padding?
For stracture : Memory(int+float+char)
For Union :
Max(int,float,char)
Depending on architecture
Union Will take 4 bytes because int and char are of 4 bytes but char will take 1 byte then the union will take 4 bytes and In structure, it will take 9 bytes. This was the answer to this quiz.
@@36kaudi31 exactly
@@36kaudi31
It will be 12 due to structure padding
Right
@@36kaudi31 It depends on the architecture, As i have seen on mac book float is of 8 bytes.
Structure : My memory
Union : Our memory
Nice
4 in union(coz of here float has the largest memory)and 9in structures
But when I use sizeof() function to print size of that structure dataType ..it pritns 12 ..but why????
actually it 9 right.
@@ashishgupta7849 char takes 1 byte.
@@ashishgupta7849 it is not necessary that in your computer int or char or float is taking 8 bytes it depends on your memory
@@ashishgupta7849 Bro it's actually 12 only . In structure memory is reserved in the order of the largest data type .
Int float char
So 4 for int , 4 for float,and 4 for char instead of 1 so that it remains continuous in the order of largest data type. Hope it helps
@@ss877S
Yaa due to structure padding...
9 in structure and 4 in union
Union will take 4
Structure will take 9
16 for structure
Samajh me aa gaya hai.
Thank you Harry bhaii.. for this masterpiece course..💓💓
11:53 For Structures: It takes 4+4+1=9 bytes, For Union: It takes the max(4,4,1) = 4 Bytes
Your effort is really appreciable , till 2022 it is very helpfull for beginners
Thanks to providing this amzaing content❤👍❤
12:11 For Union 4 bytes and for Structure 9 bytes of memory will be allocated.
In this the float will take more byte is up to 4 byte and in the structure, it will take adding all the byte use in the code is (11 byte).
Thanks for explanning this concept more easily.
itna acchese unioin aaj tak kisi ne nahi samjhaya
maje aa gaye
harry bhaiya ❤️
concept is crystal clear in one time watched.
Sir aap aise hi videos bnaye rho u are doing a really good job
Kya badhiya explain karte ho bhaiyya
...
Aisa lagta hai kahani sun rahe hai..
Aur sunte sunte sara samaj bhi aa jata hai..☺️☺️
Keep this good work going on bro...
Thanks Harry Bhaiya
Sir, you are such a great teacher,
hats off to you sir for making such videos.
Sir outstanding Tutorial aap bahut achha kam kr rhe ho sir aap C pr project bna kr v dikhawo plz... sir......and jo v project (koi software with the help of c ) chahte h c pr to like kro
Yes ,this is good idea
Harry Bhai u r great really respect u
For structure float+int+char(4+2+1)
For Union :- Float (4)
Thank you so much sir 😊
Because of you only I have understood the concept perfectly 🥰
AWESOME MAN ✌✌KEEP ROCKING✌
4 in union(float is the largest taking 4 bytes) and 7 in structure(integer takes 2 bytes+ float takes 4 bytes + char takes 1 byte. So total 7 bytes)
Lastly,
Union -> 4 bytes
Structure -> 7 bytes
for structure = { int + float + char}
for union = Max{ int , float , char } ( Depending on architecture )
Excellent and best coder in you tube
This was really a helpful and knowledgeable video. Thanks bhiya ji
you are the best harry bhai
Nice Explanation Sir
Thank You Sir
👍
You teach very well.
Harry Bhai! I understood.
For structure :- float+int+char(I think 4+2+1)
For Union :- Float (4 acc to me )
Thank You.
Sir you are doing a good job for us
And Iam pray to God for you,That
you got what do you want.And keep
achieving..
... thank you
Thank you very much
harry sir aap bahut hi accha samjhate hai thanks for this video
union will take size : printf("%d",sizeof(test));
structure will take size : printf("%d",sizeof(test));
because size vary architecture to architecture
Thanks Harry Da.....❤
QUICK QUIZ : ---
depending on the architecture
otherwise it would take
4 Bytes in Union
and
9 Bytes in Structures ( int 4 Bytes + float 4 Bytes + char 1 Bytes =9 Bytes )
Thank you very much bhaiya🙏
It's depending on architecture.
if, int=4 bit
float =4 bit
& char=2 bit
then union of int,float,char will be 4 bit .
and in structure it consume 10 bit memory.
11:53 Union memory 4 bytes
Structure memory 9 bytes
Drum example is one of the best 👌
4:48 best example of drumm ऐसे भी drum सेट ही होता है और बजाने वाले के हाथ में दो ही स्टिक होती है जो संगीत के हिसाब से बजाता है। drum set and two stik is perfect example
According to highest member of larger memory assigned to union that is float
11:58 union will take the memory equal to the size of float on that architecture
for a structure it would take the size equal to the sum of all sizes (int+char+float)
Incredible 💜💜
11:43 4 for union and for structure 12 for 64 bit architechture
Thank you 🙏
Thank you sir ❤❤
Very well explained
11:59
In union,
max(int,float,char)= 4 bytes
In structure,
(Int + float + char)=9 bytes
nice explNtion haRRY bhai
11:51 ---------> size will be 4bytes for union(max for floats, yet depends on cpu) and 2+4+1=7 bytes for Structure(assuming my cpu allocates 2 bytes for Integer)
size of union is depends on compiler to compiler, According to my compiler it stores 4 bytes in union best highest is 4 bytes which is float data type and 9 bytes of data in structure.
Memory required for union and structure are 4 and 9 bytes respectively.
12:12-->Struct(int's 4bytes+char's 1byte+float's 4byte=9bytes). Union(the largest of the three memory i.e either float/int=4bytes)
thanks for this explain
structure-9 bytes because int(4 bytes),float (4 bytes) and char(1 byte).
union-4 bytes
for structure it will take memory space of all three (int +float+char)
but,
in union it will take only one type of memory space either of float or int depends on the architect(not mention char as it takes only one byte in every architechture which is less than int or float)
Great 🌟
for union memory will be 4 bytes and for structure it will be 4+4+1 = 9 bytes
bhai can you please say why strcpy is used to copy name rather than just saying s1.name="harry".......
because you cannot directly assign string name to array, which is char name[34] here
@@svikash6464 jb array create kar rkha hoga for ex char s[100] for strcpy ka use karenge
lekin agr char *s; h to directly name kar skte hn
@@hemangkoshiyar2586 yes
12:10
for union : 4 byte;
for structure : 9 byte;
Union: 4 (because here float take 4 byte and here its maximum between other two) and in structure : 4 for float, 4 for int, 1 for char which is 9
Ps. Size of data type is vary according to the architecture of system
11:49 Depending on architecture
THANK YOU SIR
For union it takes 4 byte and for structure it takes 9 bytes in 32 bit compiler
The memory size allocated to the union shown in the quick quiz would be equal to the biggest data type in it which is float
it is depend on architecture somewhere int and float use 4 bytes and somewhere it is 2bytes
4 bytes for union && 9 bytes for stucture accordingly to the architecture of your system
according to the architecture we have to check
max{int,float,char}, in general cases ans for union is 4
for struct it is sum of all that is 9.
Thanks sir
structure will take (int+float+char) = 8 bytes it is for 64-bit for 32-bit it will take 5 bytes
union will take max memory = (int,float) = 4 bytes for 64-bit for 32-bit = 2 bytes
Size of union will be equal to size of floati i.e (4). Depends on artchicture
It will take 4 bits in union and 9 bits in structure but it will also depend on the architecture
It's ACC to compiler in my computer int takes 2 bytes float takes 4 and char takes 1
So for struct (4+2+1) it's 7
And for union it's 4
11:55 union :-Float data type ki memory allocate hogi kyoki maximum memory consuming data type float he teeno me
Structure:- wo int ,float or char teeno ki memory ka sum allocate hoga (accordingto architecture memoryis diffrent)
structure =(int + float + char) =9
union = 4
depend on architecture
bhai can you please say why strcpy is used to copy name rather than just saying s1.name="harry".......
smjh aagya
I takes 7 bytes in memory location for structures... because 2 for int , 1 for char and 4 for float....and on the other hand...it takes 4 bytes in unions Because that is the largest size memory...and btw ...all depends on the architecture...coz based on architecture to architecture 👍
write architecture early, my whole knowledge goes damn after looking on your answer at #39 🤯🤧
1st like 2nd comment....Thank u for providing us such great videos...😄😄😄😄😊
11:51 the size of union will be 4 bytes as the maximum space in union is of float(4 bytes)
Harry bhai
It get 4byte memory becoz float sbse jada as compare to int ,char
According to structure total =9 byte
Int (4byte)+float (4byte)+char(1byte).
Yes , Mai pura starting se video dekh rha hu☝️
for Union, maximum byte from any of int or float or char and for structure, int + float + char = ____
Among all float has the highest memory so memory of float will be given. As we also know the memory defer from architecture to architecture but in 32 -arch its 4 byte
ANS if its structure it will take 9 byte as in 32-arch int is 4 byte float is 4 byte and char is 1 so adding all we will get 9 byte
Great
Aagya sir ji 🙏🙏
This union will Use as much memory as float uses
As float uses large memory or bytes when compared to int and char
harry bhai drum wali analogy bawal hai
Bhai, Aapne to yeh bhut badiya course bnaya hain aur wo bhi free mein..Maine aapke Courses ko College ke Official WhatsApp group pe share krta hoon....
Struct: 7( 1char + 2int + 4float)
Union:4 (cuz of float)
in structure 12 and in union 7 in my case of computer because in my float take about 7 or 6 bytes and int 4 and char 1 and if do union so it would be 7 or 6 only.
12:10 Union will consume 4 bytes of memory according to 64-bit architecture & structure will consume 9 bytes of memory.
for structure = 4 (int) + 4 (float) + 1 (char) = 9
for union = max ( 4 (int) , 4 (float) , 1 (char)) = 4
according to 64 bit architecture:
union will allocate 4 bit memory
and structure will 9 bit memory.
11:54 According to my architecture 4 bytes shared among float int and char
#quizanswer
according to my Architecture union takes 4 bytes and structure takes 9 bytes
It's right
Please explain brief I can't understand 🙏🙇
@@sanmatipol3201 have you seen the video? You have to look in your system and find that your windows is of 64-bits or 32-bits..
And if your windows is 64-bits than your answer will be same as mine.
You don't need to understand bcz it's already defined..
@@vaibhavbhardwaj48 thank you very much 😊😇.
@@sanmatipol3201 mention not
Union : 4bytes
Structure: 9bytes
But the answer might vary , because of the architecture ; So better once to check by sizeof() operator to know the exact memory space int, float and char would take
nice one!!!
Nice
yes
12:18
(4+4+1)=9 bytes in struct
4 bytes in union
It depends on what architecture you are using. In my architecture,in case of union it takes 4bytes, because float takes 4bytes. In case of Structure,it takes (4+4+1)=9bytes
for union
size of float, int in my architecture is 4 and char is 1..so 4+1= 5
Union float ke according and structure int+float+char ke according memory consume karega