Application of Unions (Part 2)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • C Programming: Application of Unions in C Programming.
    Topics discussed:
    1) Creating your own mixed type of data structure.
    C Programming Lectures: goo.gl/7Eh2SS
    Follow Neso Academy on Instagram: @nesoacademy(bit.ly/2XP63OE)
    Follow me on Instagram: @jaspreetedu(bit.ly/2YX26E5)
    Contribute: www.nesoacademy...
    Memberships: bit.ly/2U7YSPI
    Books: www.nesoacademy...
    Website ► www.nesoacademy...
    Forum ► forum.nesoacade...
    Facebook ► goo.gl/Nt0PmB
    Twitter ► / nesoacademy
    Music:
    Axol x Alex Skrindo - You [NCS Release]
    #CProgrammingByNeso #CProgramming #UnionsInC #UnionApplications #Structure&Union

ความคิดเห็น • 46

  • @pranayhusukale2666
    @pranayhusukale2666 4 ปีที่แล้ว +10

    Plz make videos on data structures that would tune my future becoz i love the way explained it is a great experience learning with you

  • @garetts8156
    @garetts8156 4 ปีที่แล้ว +4

    I have a question - isn't that that in case of struct of this example you can have 30 different values (3 values for each element of the array, f.e. a[0].a, a[0].b, a[0].c ) and in case of union you can only have 10 different values ( 1 value per element as only one of three values can be initialized at given time as they have the same address)?

    • @harcharansingh1997
      @harcharansingh1997 4 ปีที่แล้ว +5

      a [0]•a is allowed but a [0].b is not allowed because a [0] contain only one value at one time we can not enter three differt value at one location .
      Thank u hope u understand

    • @phani2739
      @phani2739 4 ปีที่แล้ว

      @@harcharansingh1997 I think that is wrong you can assign value to a[0].a , a[0].b , a[0].c .

    • @kausachan4167
      @kausachan4167 3 ปีที่แล้ว +2

      @@phani2739 ya you can do that but if you do so, then all the members will get affected

    • @kausachan4167
      @kausachan4167 3 ปีที่แล้ว

      @@harcharansingh1997 nice one

    • @areebshaikh321
      @areebshaikh321 3 ปีที่แล้ว

      @garett's you're correct

  • @prashanttyagi5477
    @prashanttyagi5477 4 ปีที่แล้ว +2

    Sir your explaination is sooo good,
    Please make the videos on DAA(Design and Analysis of Algorithm) if possible.

  • @wowhehee4709
    @wowhehee4709 4 ปีที่แล้ว +2

    Sir please make a course on python programming due to it joint in physics graduation course also
    Plz sir

  • @sanket8313
    @sanket8313 ปีที่แล้ว

    i love your explanation so much . I will definitely donate when i will be placed

  • @akhilgupta3664
    @akhilgupta3664 4 ปีที่แล้ว +1

    Your videos are always great !! and
    Sir please make presentation on DAA (design and analysis of algorithm)

  • @badxcode
    @badxcode 4 ปีที่แล้ว +8

    when we change assign a value to a union variable then other variable of that union also gets reflected with the same value. Why here only the union variable we assign value to gets change and the rest stays empty??????

    • @Dnsx_plus
      @Dnsx_plus 3 ปีที่แล้ว +5

      What do you mean, we created 10 separate unions of data type data, so if we change the first union[0], the other unions don't get reflected since they're separate ones.

    • @vinaykumarreddy9956
      @vinaykumarreddy9956 3 ปีที่แล้ว +5

      each array element is of typeof union. so a[0] is union type and a[1],a[2],a[3]....a[9] all elements having 3 members(int,char,double)in it but memory is allocated based on highest datatype in union. so we can assign only one member in each array element

  • @jk47nitk
    @jk47nitk 2 ปีที่แล้ว

    Good example of array of mixed data type

  • @krishnakumarr2466
    @krishnakumarr2466 4 ปีที่แล้ว +1

    Please do a presentation on dynamic memory allocation if possible.

  • @Olavotemrazaodenovo
    @Olavotemrazaodenovo 4 ปีที่แล้ว +1

    Very. Good

  • @belalyahya6338
    @belalyahya6338 3 ปีที่แล้ว

    Amazing, Marvelous
    I'm very thankful for such lectures

  • @kesavanram3657
    @kesavanram3657 3 ปีที่แล้ว

    in structure the order is int,char,double. int take 4 bytes, char takes 1 byte and the rest three bytes is empty and double takes 8 bytes , total it will be 16 byte according to structure padding tutorial. here how it became 13 byte without pack(1).

    • @areebshaikh321
      @areebshaikh321 3 ปีที่แล้ว

      He has taking packing into consideration, but hasn't written in the code.

  • @thinhnguyenvan7003
    @thinhnguyenvan7003 3 ปีที่แล้ว

    Yes. This is greate case study for using union. I think

    • @thinhnguyenvan7003
      @thinhnguyenvan7003 3 ปีที่แล้ว

      But how can we read this data from this mixed array?

  • @priyam_1007
    @priyam_1007 4 ปีที่แล้ว +1

    Thanks 😊😊

  • @shiyadh4471
    @shiyadh4471 4 ปีที่แล้ว +1

    Geaaaaaat explation ever.......

  • @saddamahmad2310
    @saddamahmad2310 4 ปีที่แล้ว +1

    thank you very much sir for this video

  • @ki_san321
    @ki_san321 3 ปีที่แล้ว +1

    You can Print this like this
    #include//Array Of Mixed Data
    #include
    typedef union
    {
    int a;
    char *b;
    float c;
    long int d;

    }data;
    void main()
    {
    data array[3];//typedef rakhesi data tyepe ma union rakhhna pardaina
    array[0].a= 45;
    array[1].b='R';
    array[2].c=31.67;
    array[3].d=44;
    printf("%d %c %.3f %ld",array[0].a,array[1].b,array[2].c,array[3].d);
    getch();
    }

  • @sivashankaribadrinarayanan1272
    @sivashankaribadrinarayanan1272 3 ปีที่แล้ว

    Array will take same data types know how it accepts mixture of data type

  • @abheejitjadhav9405
    @abheejitjadhav9405 4 ปีที่แล้ว

    Pls make video on how to calculate complexity and how it can be optimised

  • @aryanraj7256
    @aryanraj7256 ปีที่แล้ว

    what will be the data specify while printing the array ?

  • @lsgtalk1996
    @lsgtalk1996 3 ปีที่แล้ว

    Very thankful 🙏

  • @kunalsoni7681
    @kunalsoni7681 4 ปีที่แล้ว

    wow nice and awesome presentation sir

  • @suheabkhan2546
    @suheabkhan2546 4 ปีที่แล้ว

    V good sir.. .. V luv ur teaching

  • @vinayak4778
    @vinayak4778 2 ปีที่แล้ว

    Thanks

  • @user-bu8mg7uq3s
    @user-bu8mg7uq3s 3 ปีที่แล้ว

    thank you

  • @hadireg
    @hadireg 4 ปีที่แล้ว

    another great example :D 👍🙏

  • @Hj.harshjain
    @Hj.harshjain 4 ปีที่แล้ว

    Amazing videos please explain Java also😊

    • @prafullsonawane9468
      @prafullsonawane9468 4 ปีที่แล้ว

      Nice explanation, i have one question, the mix data type array is nice concepts but what will be the its real time application..?

  • @sumit49
    @sumit49 3 ปีที่แล้ว

    i thnik by using structure also some memory getting wasted .

  • @ashishsingh7056
    @ashishsingh7056 4 ปีที่แล้ว +1

    please make the vedio on python
    😰😰😰😰😰🙏🙏🙏🙏🙏

  • @krishnabhagat2716
    @krishnabhagat2716 4 ปีที่แล้ว

    Can can i got all of your lecture slides please!.

  • @tamminedikrishnamohan6155
    @tamminedikrishnamohan6155 2 ปีที่แล้ว

    This is not a good example to compare union and structure.
    As per above union definition, one can store 10 different values only. Where as in structure we can store 30 values !

    • @Joshua-sp1kd
      @Joshua-sp1kd 2 ปีที่แล้ว

      Exactly. Perhaps we want to use a char, int, and double in one array element. We cannot do that using a union, only structure

  • @ashishsingh7056
    @ashishsingh7056 4 ปีที่แล้ว

    please make the vedio on python

  • @ssc_-kn6os
    @ssc_-kn6os 3 ปีที่แล้ว

    Again name of union in very first application is missing

  • @excitedbox5705
    @excitedbox5705 4 ปีที่แล้ว +2

    Video about wasting space. Repeats himself multiple times. ;)

    • @llll-qz9kr
      @llll-qz9kr 3 ปีที่แล้ว +2

      if he didnt we'd have to rewind to refresh, which then loops over everything on the rewind as well as the playback
      it's a huge optimization :)
      (.. is it? I have no clue lmao)