Computer Science, asked by sayalidoshi315, 16 days ago

Write a program to implement the use of union of structures.​

Answers

Answered by Anonymous
2

Answer:

When a union is defined, it creates a user-defined type. However, no memory is allocated. To allocate memory for a given union type and work with it, we need to create variables.

Here's how we create union variables.

union car

{

char name[50];

int price;

};

int main()

{

union car car1, car2, *car3;

return 0;

}

Another way of creating union variables is:

union car

{

char name[50];

int price;

} car1, car2, *car3;

In both cases, union variables car1, car2, and a union pointer car3 of union car type are created.

Explanation:

l hope it will help u

Similar questions