Computer Science, asked by Sheren3376, 9 months ago

Write a C program to declare, initialize an union

Answers

Answered by abhinavsaha2003
1

 the c pogram is declare for c disk

Answered by goutamipurra
0

Answer:

union union_name{<data-type>element 1;

<data-type>element 2;

<data-type>element 3;}union_variable;

EXAMPLE:

struct tggedItem{

enum{iType,fType,cType}tag;

union{

int ival;

float fval;

char *sval;

}u;

};

Explanation:

Initialization:

  • Union may only be initialized to a value appropriate for the type of its first member.
  • The other types can only be initialized by assigning values or reading values into the union.
Similar questions