Program to delete duplicates from a link list

Union in C

 Union :-
                Union in C/c++ is predefine data type 
  1. Capable of grouping different types data items in a single unit.
  2. The union variable is allocated a common memory equal to the memory size required by the maximum sized data member.
  3. All members share the same common memory but one at a time .
  4. Union are used to efficiently use the memory.

if int = 2 byte , char = 1 bytes , float =4 bytes for the 16 bits architecture

example of union in c:-

/* WAP to  read name, id and display by using union data type*/ 
union emp
    char name[20];
    int id;
    float sal;

int main()
    printf("Enter id of employee\n");
    printf("ID - %d\n",;
    printf("Enter name of employee\n");
    printf("Name - %s\n",;
    printf("Enter salary of employee\n");
    printf("Salary - %f\n",e1.sal);
    return 0;


Enter id of employee
ID - 12568
Enter name of employee
Name - Rajnish
Enter salary of employee
Salary - 85568.226562

Union in C

Recommended Post:

Key points:-

Cracking the coding interview:-

Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-


Leave a Reply

Your email address will not be published.