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
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
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)?
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
@@harcharansingh1997 I think that is wrong you can assign value to a[0].a , a[0].b , a[0].c .
@@phani2739 ya you can do that but if you do so, then all the members will get affected
@@harcharansingh1997 nice one
@garett's you're correct
Sir your explaination is sooo good,
Please make the videos on DAA(Design and Analysis of Algorithm) if possible.
Sir please make a course on python programming due to it joint in physics graduation course also
Plz sir
i love your explanation so much . I will definitely donate when i will be placed
Your videos are always great !! and
Sir please make presentation on DAA (design and analysis of algorithm)
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??????
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.
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
Good example of array of mixed data type
Please do a presentation on dynamic memory allocation if possible.
Very. Good
Amazing, Marvelous
I'm very thankful for such lectures
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).
He has taking packing into consideration, but hasn't written in the code.
Yes. This is greate case study for using union. I think
But how can we read this data from this mixed array?
Thanks 😊😊
Geaaaaaat explation ever.......
thank you very much sir for this video
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();
}
Array will take same data types know how it accepts mixture of data type
Pls make video on how to calculate complexity and how it can be optimised
what will be the data specify while printing the array ?
Very thankful 🙏
wow nice and awesome presentation sir
V good sir.. .. V luv ur teaching
Thanks
thank you
another great example :D 👍🙏
Amazing videos please explain Java also😊
Nice explanation, i have one question, the mix data type array is nice concepts but what will be the its real time application..?
i thnik by using structure also some memory getting wasted .
please make the vedio on python
😰😰😰😰😰🙏🙏🙏🙏🙏
Can can i got all of your lecture slides please!.
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 !
Exactly. Perhaps we want to use a char, int, and double in one array element. We cannot do that using a union, only structure
please make the vedio on python
Again name of union in very first application is missing
Video about wasting space. Repeats himself multiple times. ;)
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)