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

Комментарии • 847

  • @madhurajput452
    @madhurajput452 2 года назад +286

    For structure: 4+4+1=9
    (int+float+char)
    For union: max(4,4,1)=4
    max(int,float,char)

    • @klredits1790
      @klredits1790 Год назад +2

      well explained

    • @madhurajput452
      @madhurajput452 Год назад +2

      @@klredits1790 Thank you

    • @gametechz_
      @gametechz_ Год назад +3

      Good explained

    • @prashantkawathe933
      @prashantkawathe933 Год назад +5

      U are right about union but for structure it will take 12 bytes instead of 9 byte because of structure padding

    • @emkaywho
      @emkaywho Год назад

      @@prashantkawathe933 what's structure padding?

  • @digilifeindia8557
    @digilifeindia8557 4 года назад +194

    For stracture : Memory(int+float+char)
    For Union :
    Max(int,float,char)
    Depending on architecture

    • @36kaudi31
      @36kaudi31 3 года назад +14

      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.

    • @manpreetsinghcse8263
      @manpreetsinghcse8263 3 года назад +3

      @@36kaudi31 exactly

    • @handekarilingojivarasaikri782
      @handekarilingojivarasaikri782 3 года назад +1

      @@36kaudi31
      It will be 12 due to structure padding

    • @TwinshuParmar
      @TwinshuParmar 3 года назад +1

      Right

    • @TwinshuParmar
      @TwinshuParmar 3 года назад +2

      @@36kaudi31 It depends on the architecture, As i have seen on mac book float is of 8 bytes.

  • @pho3nix732
    @pho3nix732 2 года назад +22

    Structure : My memory
    Union : Our memory

  • @dimplegulwani8981
    @dimplegulwani8981 3 года назад +108

    4 in union(coz of here float has the largest memory)and 9in structures

    • @ashishgupta7849
      @ashishgupta7849 3 года назад +4

      But when I use sizeof() function to print size of that structure dataType ..it pritns 12 ..but why????
      actually it 9 right.

    • @_Ro_HiT
      @_Ro_HiT 3 года назад +1

      @@ashishgupta7849 char takes 1 byte.

    • @geeli_puppy_.
      @geeli_puppy_. 3 года назад +4

      @@ashishgupta7849 it is not necessary that in your computer int or char or float is taking 8 bytes it depends on your memory

    • @ss877S
      @ss877S 3 года назад +7

      @@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

    • @handekarilingojivarasaikri782
      @handekarilingojivarasaikri782 3 года назад +4

      @@ss877S
      Yaa due to structure padding...

  • @AliHussain-sj7cb
    @AliHussain-sj7cb 5 лет назад +21

    9 in structure and 4 in union

  • @hamitdes7865
    @hamitdes7865 4 года назад +73

    Union will take 4
    Structure will take 9

  • @rahulkumarkeshriiitbhu3932
    @rahulkumarkeshriiitbhu3932 Год назад +3

    Samajh me aa gaya hai.
    Thank you Harry bhaii.. for this masterpiece course..💓💓

  • @gokubytee
    @gokubytee Год назад +9

    11:53 For Structures: It takes 4+4+1=9 bytes, For Union: It takes the max(4,4,1) = 4 Bytes

  • @sudhanshujain1017
    @sudhanshujain1017 2 года назад +8

    Your effort is really appreciable , till 2022 it is very helpfull for beginners
    Thanks to providing this amzaing content❤👍❤

  • @ayanavadas6154
    @ayanavadas6154 2 года назад +7

    12:11 For Union 4 bytes and for Structure 9 bytes of memory will be allocated.

  • @alkalinelife6110
    @alkalinelife6110 2 года назад +3

    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.

  • @nikhilmeena2196
    @nikhilmeena2196 3 года назад

    itna acchese unioin aaj tak kisi ne nahi samjhaya
    maje aa gaye
    harry bhaiya ❤️

  • @Piyush_Sharma--
    @Piyush_Sharma-- Год назад

    concept is crystal clear in one time watched.

  • @dexterpro3502
    @dexterpro3502 5 лет назад +3

    Sir aap aise hi videos bnaye rho u are doing a really good job

  • @shahnawazsayyed6053
    @shahnawazsayyed6053 3 года назад

    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...

  • @royfamily9273
    @royfamily9273 2 года назад

    Thanks Harry Bhaiya

  • @harshsaini2000
    @harshsaini2000 2 года назад +1

    Sir, you are such a great teacher,
    hats off to you sir for making such videos.

  • @NishchhalPrajapatCs_
    @NishchhalPrajapatCs_ 5 лет назад +13

    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

  • @snehbandhusingh3449
    @snehbandhusingh3449 4 года назад

    Harry Bhai u r great really respect u

  • @_jayVaghela
    @_jayVaghela 3 года назад +17

    For structure float+int+char(4+2+1)
    For Union :- Float (4)

  • @saifboi34
    @saifboi34 2 года назад

    Thank you so much sir 😊
    Because of you only I have understood the concept perfectly 🥰

  • @user-ur9tk1qd4r
    @user-ur9tk1qd4r 3 года назад +1

    AWESOME MAN ✌✌KEEP ROCKING✌

  • @apurvakumardani172
    @apurvakumardani172 2 года назад +4

    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

  • @harshgupta-os2pq
    @harshgupta-os2pq 3 года назад +5

    for structure = { int + float + char}
    for union = Max{ int , float , char } ( Depending on architecture )

  • @codewithharryfanchannel559
    @codewithharryfanchannel559 5 лет назад

    Excellent and best coder in you tube

  • @Sovit705
    @Sovit705 3 года назад

    This was really a helpful and knowledgeable video. Thanks bhiya ji

  • @TaLLon121
    @TaLLon121 Год назад

    you are the best harry bhai

  • @techwithcsk7890
    @techwithcsk7890 2 года назад

    Nice Explanation Sir
    Thank You Sir
    👍

  • @krishsharma5065
    @krishsharma5065 3 года назад +1

    You teach very well.

  • @chiragpabari6740
    @chiragpabari6740 Год назад

    Harry Bhai! I understood.

  • @ankursapariya1738
    @ankursapariya1738 3 года назад +20

    For structure :- float+int+char(I think 4+2+1)
    For Union :- Float (4 acc to me )
    Thank You.

  • @siddhantrajdeo531
    @siddhantrajdeo531 Год назад

    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

  • @saptarshiroy9824
    @saptarshiroy9824 2 года назад

    Thank you very much

  • @Learn_coding218
    @Learn_coding218 Год назад

    harry sir aap bahut hi accha samjhate hai thanks for this video

  • @nareshgoyal1994
    @nareshgoyal1994 4 года назад +14

    union will take size : printf("%d",sizeof(test));
    structure will take size : printf("%d",sizeof(test));
    because size vary architecture to architecture

  • @moneymindz123
    @moneymindz123 4 месяца назад

    Thanks Harry Da.....❤

  • @VanshPruthi-mk4pq
    @VanshPruthi-mk4pq 22 дня назад +2

    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 )

  • @Karthik-kt24
    @Karthik-kt24 3 года назад

    Thank you very much bhaiya🙏

  • @MizanurRahaman03
    @MizanurRahaman03 3 года назад +1

    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.

  • @JenilMendpara
    @JenilMendpara Год назад +5

    11:53 Union memory 4 bytes
    Structure memory 9 bytes

  • @OfficialTheArk1433
    @OfficialTheArk1433 2 года назад

    Drum example is one of the best 👌

  • @victorb22622
    @victorb22622 Месяц назад

    4:48 best example of drumm ऐसे भी drum सेट ही होता है और बजाने वाले के हाथ में दो ही स्टिक होती है जो संगीत के हिसाब से बजाता है। drum set and two stik is perfect example

  • @NitinKumar-qk1fi
    @NitinKumar-qk1fi 4 года назад

    According to highest member of larger memory assigned to union that is float

  • @satvikmittal4487
    @satvikmittal4487 2 года назад

    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)

  • @pallavisinghpallavisingh1786
    @pallavisinghpallavisingh1786 2 года назад

    Incredible 💜💜

  • @factzandcode
    @factzandcode 2 года назад +1

    11:43 4 for union and for structure 12 for 64 bit architechture

  • @letsgo178
    @letsgo178 3 года назад

    Thank you 🙏

  • @Gayatri_shejule
    @Gayatri_shejule 8 месяцев назад

    Thank you sir ❤❤

  • @muhammadbasit6176
    @muhammadbasit6176 3 года назад

    Very well explained

  • @anujsarda5038
    @anujsarda5038 2 года назад +1

    11:59
    In union,
    max(int,float,char)= 4 bytes
    In structure,
    (Int + float + char)=9 bytes

  • @sidhxrth1819
    @sidhxrth1819 3 года назад

    nice explNtion haRRY bhai

  • @AlinjanArts
    @AlinjanArts 3 года назад

    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)

  • @tanveerjafri3052
    @tanveerjafri3052 5 лет назад

    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.

  • @adarshraj3208
    @adarshraj3208 3 года назад +1

    Memory required for union and structure are 4 and 9 bytes respectively.

  • @rosonerri-faithful
    @rosonerri-faithful 2 года назад +2

    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)

  • @Sush2503
    @Sush2503 3 года назад +1

    structure-9 bytes because int(4 bytes),float (4 bytes) and char(1 byte).
    union-4 bytes

  • @abcefg7045
    @abcefg7045 3 года назад

    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)

  • @technicalsandie42
    @technicalsandie42 2 года назад

    Great 🌟

  • @shivanshmahajan2281
    @shivanshmahajan2281 2 года назад +9

    for union memory will be 4 bytes and for structure it will be 4+4+1 = 9 bytes

    • @svikash6464
      @svikash6464 2 года назад

      bhai can you please say why strcpy is used to copy name rather than just saying s1.name="harry".......

    • @hemangkoshiyar2586
      @hemangkoshiyar2586 2 года назад

      because you cannot directly assign string name to array, which is char name[34] here

    • @artifice_abhi
      @artifice_abhi 2 года назад

      @@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

    • @artifice_abhi
      @artifice_abhi 2 года назад

      @@hemangkoshiyar2586 yes

  • @bharatbardiya2362
    @bharatbardiya2362 3 года назад +2

    12:10
    for union : 4 byte;
    for structure : 9 byte;

  • @aryapankaj7076
    @aryapankaj7076 2 года назад

    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

  • @shubhamgupta3396
    @shubhamgupta3396 3 года назад +1

    11:49 Depending on architecture

  • @kamalthakur9749
    @kamalthakur9749 Год назад

    THANK YOU SIR

  • @vishwajeet5499
    @vishwajeet5499 Год назад +1

    For union it takes 4 byte and for structure it takes 9 bytes in 32 bit compiler

  • @technikalproblem6780
    @technikalproblem6780 9 месяцев назад

    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

  • @soumitrasharma9952
    @soumitrasharma9952 3 года назад

    it is depend on architecture somewhere int and float use 4 bytes and somewhere it is 2bytes

  • @rahulyo.gaming
    @rahulyo.gaming 3 года назад +1

    4 bytes for union && 9 bytes for stucture accordingly to the architecture of your system

  • @AakashSingh-jv3vd
    @AakashSingh-jv3vd 2 года назад

    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.

  • @AvinashKumar-gk9in
    @AvinashKumar-gk9in 3 года назад

    Thanks sir

  • @ankeshkumar5753
    @ankeshkumar5753 4 года назад +1

    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

  • @AmanSingh-yy4fn
    @AmanSingh-yy4fn 3 года назад +1

    Size of union will be equal to size of floati i.e (4). Depends on artchicture

  • @letscode6600
    @letscode6600 3 года назад

    It will take 4 bits in union and 9 bits in structure but it will also depend on the architecture

  • @anshbhardwaj9467
    @anshbhardwaj9467 10 месяцев назад +1

    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

  • @atifmalik8012
    @atifmalik8012 2 месяца назад

    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)

  • @InfinityInsights758
    @InfinityInsights758 2 года назад +2

    structure =(int + float + char) =9
    union = 4
    depend on architecture

    • @svikash6464
      @svikash6464 2 года назад

      bhai can you please say why strcpy is used to copy name rather than just saying s1.name="harry".......

  • @kabirkrishna2583
    @kabirkrishna2583 6 месяцев назад

    smjh aagya

  • @anushreetiwari2363
    @anushreetiwari2363 3 года назад +4

    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 👍

    • @Agroot0
      @Agroot0 Год назад

      write architecture early, my whole knowledge goes damn after looking on your answer at #39 🤯🤧

  • @ShinChan-cu8ns
    @ShinChan-cu8ns 5 лет назад +2

    1st like 2nd comment....Thank u for providing us such great videos...😄😄😄😄😊

  • @devprakash6608
    @devprakash6608 Год назад

    11:51 the size of union will be 4 bytes as the maximum space in union is of float(4 bytes)

  • @aakasharora8859
    @aakasharora8859 3 года назад

    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).

  • @babaanimation5511
    @babaanimation5511 3 года назад

    Yes , Mai pura starting se video dekh rha hu☝️

  • @FLeZyGaming
    @FLeZyGaming 4 года назад

    for Union, maximum byte from any of int or float or char and for structure, int + float + char = ____

  • @riyasingh3559
    @riyasingh3559 3 года назад

    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

  • @RohanDasRD
    @RohanDasRD 5 лет назад

    Great

  • @harshitpanwar550
    @harshitpanwar550 Год назад

    Aagya sir ji 🙏🙏

  • @yashsisodia_6061
    @yashsisodia_6061 3 года назад

    This union will Use as much memory as float uses
    As float uses large memory or bytes when compared to int and char

  • @truefalse7059
    @truefalse7059 2 года назад

    harry bhai drum wali analogy bawal hai

  • @hefshineshubhamkirme3354
    @hefshineshubhamkirme3354 3 года назад

    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....

  • @Baby-oc2xt
    @Baby-oc2xt 2 года назад

    Struct: 7( 1char + 2int + 4float)
    Union:4 (cuz of float)

  • @abdulmunim5915
    @abdulmunim5915 3 года назад

    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.

  • @himang09
    @himang09 2 года назад

    12:10 Union will consume 4 bytes of memory according to 64-bit architecture & structure will consume 9 bytes of memory.

  • @parul8334
    @parul8334 Год назад +1

    for structure = 4 (int) + 4 (float) + 1 (char) = 9
    for union = max ( 4 (int) , 4 (float) , 1 (char)) = 4

  • @MUHAMMADIBRAHIM-up3mb
    @MUHAMMADIBRAHIM-up3mb 3 года назад +2

    according to 64 bit architecture:
    union will allocate 4 bit memory
    and structure will 9 bit memory.

  • @jayanspaliwal5907
    @jayanspaliwal5907 2 года назад

    11:54 According to my architecture 4 bytes shared among float int and char

  • @vaibhavbhardwaj48
    @vaibhavbhardwaj48 5 лет назад +10

    #quizanswer
    according to my Architecture union takes 4 bytes and structure takes 9 bytes

    • @ayushkesarwani4233
      @ayushkesarwani4233 4 года назад +1

      It's right

    • @sanmatipol3201
      @sanmatipol3201 4 года назад

      Please explain brief I can't understand 🙏🙇

    • @vaibhavbhardwaj48
      @vaibhavbhardwaj48 4 года назад +2

      @@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..

    • @sanmatipol3201
      @sanmatipol3201 4 года назад

      @@vaibhavbhardwaj48 thank you very much 😊😇.

    • @vaibhavbhardwaj48
      @vaibhavbhardwaj48 4 года назад +1

      @@sanmatipol3201 mention not

  • @_SOHAMSAMANTA
    @_SOHAMSAMANTA 2 года назад +6

    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

  • @sDa_E_23
    @sDa_E_23 Год назад +1

    12:18
    (4+4+1)=9 bytes in struct
    4 bytes in union

  • @subhankarkanrar9494
    @subhankarkanrar9494 Год назад

    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

  • @AmanSingh-dw9li
    @AmanSingh-dw9li Год назад

    for union
    size of float, int in my architecture is 4 and char is 1..so 4+1= 5

  • @sureshkumawat3468
    @sureshkumawat3468 3 года назад

    Union float ke according and structure int+float+char ke according memory consume karega