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.
@@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
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)
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
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 👍
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.
4:48 best example of drumm ऐसे भी drum सेट ही होता है और बजाने वाले के हाथ में दो ही स्टिक होती है जो संगीत के हिसाब से बजाता है। drum set and two stik is perfect example
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
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 )
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...
that structure memory wont be exactly 9 as somewhat memory woul be allocated to padding so minimum memory occupied is 9 but its not exactly the memory size thats going to be occupied...hope this will help u frnd...:) iand the padding size is like a garbage value depends on the framework and architecture
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)
union memory size would be 4 and structure memory size should be 7 Thank you for teaching me Well the values may change depending upon the architecture
@@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..
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.
union test { int a; float b; char c; }t; t.a; t.b; t.c; printf("the size for structure would be-%d ", sizeof(t.a)+sizeof(t.b)+sizeof(t.c)); printf("the size for union is-%d", sizeof(t.a)); return 0; } this is a simple code for the answer
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 int is 2, size of float is 4, size of char is 1, union take 4 bytes(because max value of float as 4 bytes in int, float, char) struct take 7 bytes(as add-up int + float + char ) // ans. by- Manpreet Singh
Memory storage of union depends on a reasons. Reason......(.since union is also a user defined function so all members or data type takes Memory storage which is depends on computer architecture.)😊😊😊😊😊 and the last thing Present sir❤❤😂😂😂😂😂😂😂😂
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.
11:53 For Structures: It takes 4+4+1=9 bytes, For Union: It takes the max(4,4,1) = 4 Bytes
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...
Samajh me aa gaya hai.
Thank you Harry bhaii.. for this masterpiece course..💓💓
Structure : My memory
Union : Our memory
Nice
Well Represented with a soviet joke Lol
12:11 For Union 4 bytes and for Structure 9 bytes of memory will be allocated.
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
9 in structure and 4 in union
11:53 Union memory 4 bytes
Structure memory 9 bytes
For structure float+int+char(4+2+1)
For Union :- Float (4)
12:12 for structure - 9 bytes but for union - 4 bytes
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
For structure :- float+int+char(I think 4+2+1)
For Union :- Float (4 acc to me )
Thank You.
12:10
for union : 4 byte;
for structure : 9 byte;
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)
harry sir aap bahut hi accha samjhate hai thanks for this video
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
for structure = { int + float + char}
for union = Max{ int , float , char } ( Depending on architecture )
Your effort is really appreciable , till 2022 it is very helpfull for beginners
Thanks to providing this amzaing content❤👍❤
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 🤯🤧
12:18
(4+4+1)=9 bytes in struct
4 bytes in union
Union will take 4
Structure will take 9
16 for structure
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.
thanks harry sir ,you turn easy for us
Sizeof is equal to sizeof(float)
And
Sizeof is equal to sizeof(int) + sizeof(float) + sizeof(char)
for structure = 4 (int) + 4 (float) + 1 (char) = 9
for union = max ( 4 (int) , 4 (float) , 1 (char)) = 4
4:48 best example of drumm ऐसे भी drum सेट ही होता है और बजाने वाले के हाथ में दो ही स्टिक होती है जो संगीत के हिसाब से बजाता है। drum set and two stik is perfect example
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
union will take size : printf("%d",sizeof(test));
structure will take size : printf("%d",sizeof(test));
because size vary architecture to architecture
12:00
The datatype which is occupying more memory bases on the system we are using .. That memory that will allocated to Union
Wrong
@@sauravnalawade6989 why?
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 )
11:49 Depending on architecture
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...
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
Sir, you are such a great teacher,
hats off to you sir for making such videos.
structure- 9B, union - 4B
12:23 structure = 9
union = 4
11:43 4 for union and for structure 12 for 64 bit architechture
Quiz solution :
Max memory allocated for unions = int(4) + float(4) + char(1) = 4
Max memory allocated for structures = int(4) + float(4) + char(1) = 9
Thanks for such an amazing explanation ❤👍
that structure memory wont be exactly 9 as somewhat memory woul be allocated to padding so minimum memory occupied is 9 but its not exactly the memory size thats going to be occupied...hope this will help u frnd...:) iand the padding size is like a garbage value
depends on the framework and architecture
structure-9 bytes because int(4 bytes),float (4 bytes) and char(1 byte).
union-4 bytes
11:59
In union,
max(int,float,char)= 4 bytes
In structure,
(Int + float + char)=9 bytes
12:00 4bytes for union 10 bytes for struct
11:40. Structure size-> 9 bytes
Unions size-> 4 bytes
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)
. int - 4 bytes
Float - 4 bytes
Char - 1 bytes
For structure == (4+4+1)
== 9 bytes.. (structure)
For union == largest data size
== 4 bytes.. (union)
union memory size would be 4 and structure memory size should be 7
Thank you for teaching me
Well the values may change depending upon the architecture
11:55
4 bytes for union
9 bytes for structure
For structure 9 and union 4
Bhai kal tera exam hai na 😅
for structure memory required is 9
and for union memory required is 4
#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 will take 4bytes.
Int= 2-4bytes
Float= 4 bytes
Char=1byte
-Union will take the largest value.
Struct: 7( 1char + 2int + 4float)
Union:4 (cuz of float)
(Depending on Architecture)
Structure = 4+4+1(int+float+char) =9
Union = 4
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.
For stracture : Memory(int+float+char)
For Union :
Max(int,float,char)
you have to consider padding in structure
04:26 printf("harry bhai raat ko drum bjaoge 🤣🤣🤣🤣🐱🏍");
int => 4 byts
float =>4 byts
char =>1 byts
total =9 byts
union 9 bytes
12:12 structure 9 and union 4
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".......
#include
int main(){
union test
{
int a;
float b;
char c;
}t;
t.a;
t.b;
t.c;
printf("the size for structure would be-%d
", sizeof(t.a)+sizeof(t.b)+sizeof(t.c));
printf("the size for union is-%d", sizeof(t.a));
return 0;
}
this is a simple code for the answer
at 11.50 the memory of the structure will be 4+4+1(4=int,4=float,1=char) ✌✌
and for union it will be 4 bytes
concept is crystal clear in one time watched.
For structure (int,float,char) = 4+4+1=9
For union (4,4,1)= max is 4
Good
12:10 Union will consume 4 bytes of memory according to 64-bit architecture & structure will consume 9 bytes of memory.
1st like 2nd comment....Thank u for providing us such great videos...😄😄😄😄😊
11:54
If union then size = 4 bytes.
If structure then size=9 bytes.
Harry bhai : 9 Byte for Structure, and 4 byte for union
Int-2, float-4,char-1,
So union-5 and structure-7
union 4
12:12 union 4,struct 9
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
For union it takes 4 byte and for structure it takes 9 bytes in 32 bit compiler
Now, i am going to play drum after watching this whole video
12:22 Union will take 4 bytes
Structure will take 9 bytes
FOR STRUCTURE : 9
FOR UNION : 4
Structure ( 4+4+1) = 9
Union 4
For structure: 3+4+2=9
(int + float + char)
For union: max(3,4,2)=4
max(int,float,char)
Memory allocated
structure >union
For Structure :4*4+1 = 9
(int ,float,char).
For union :max(4,4,1) = 4
max(int,float ,char).
11:53 quick quiz ans = 4 byte(union)
9byte for structure
Sir aap aise hi videos bnaye rho u are doing a really good job
@12:17 for union 4 and for st 9
11:57 4 bytes will be allocated for unions.
11:49 Union memory size:4 bytes
size of int is 2,
size of float is 4,
size of char is 1,
union take 4 bytes(because max value of float as 4 bytes in int, float, char)
struct take 7 bytes(as add-up int + float + char )
// ans. by- Manpreet Singh
Quick Quiz
for union: memory size=4 bytes
for structure: memory size=(4+4+1)=9 bytes
Union:4 byte
Structure: 4+4+1=9 bytes
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
12:00 if union 4 , if struct 9
Size of union will be equal to size of floati i.e (4). Depends on artchicture
Nice Explanation Sir
Thank You Sir
👍
11:51 the size of union will be 4 bytes as the maximum space in union is of float(4 bytes)
Drum example is one of the best 👌
Memory storage of union depends on a reasons.
Reason......(.since union is also a user defined function so all members or data type takes Memory storage which is depends on computer architecture.)😊😊😊😊😊 and the last thing
Present sir❤❤😂😂😂😂😂😂😂😂
4 bytes for union && 9 bytes for stucture accordingly to the architecture of your system
4 in union and 9 in str
itna acchese unioin aaj tak kisi ne nahi samjhaya
maje aa gaye
harry bhaiya ❤️
Union take a 4 byte
Structure take a 9 byte
12:23 the correct answer is 9 byte according to 64 bit architecture......
Struct-10
Un-5
12:07 4+4+1 total 9 bytes in structure