Union Int
Union Int
{
node *curr1,*temp1,*curr2,*temp2,*head1=NULL,*head2=NULL;
int no,i,val;
printf("\nCreate 1st linklist:");
printf("\nenter the no of node:");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\nenter the value:");
scanf("%d",&val);
temp1=(node *)malloc(sizeof(node));
temp1->data=val;
temp1->link=NULL;
if(head1==NULL)
{
head1=temp1;
}
#include<stdio.h>
#include<conio.h>
#define s 5
int a[s],i,j,r=0,f=0;
void enque();
void deque();
void display();
void main()
{
int c;
clrscr();
do
{
printf("\n\t**********");
printf("\n\t1.Enqueue:\n\t2.Dequeue:\n\t3.Display:\n\t4.Exit
);
printf("\n\t**********");
printf("\n\n\tEnter the Choice =>");
scanf("%d",&c);
switch(c)
{
case 1:
enque();
break;
case 2:
deque();
break;
case 3:
display();
break;
case 4:
printf("\n\tBy =>");
exit();
}
}while(c!=4);
:"
getch();
}
void enque()
{
int item;
printf("\n\tEnter the Element::>");
scanf("%d",&item);
if(r==s)
{
printf("\n\tQueue is Full::>");
}
else
{
if(r==0 && f==0)
f=1;
r++;
a[r]=item;
}
}
void deque()
{
int temp;
if(f==0)
{
printf("\n\tQueue is Empty::>");
}
else
{
temp=a[f];
if(f==r)
f=r=0;
else
f++;
printf("\n\tDeleted Item:%d",temp);
}
}
void display()
{
printf("\n\tQueue Is::>");
for(i=f;i<=r;i++)
{
printf("%d ",a[i]);
}
}
else
{
curr1->link=temp1;
}
curr1=temp1;
}
printf("\nCreate 2nd linklist:");
printf("\nenter the no of node:");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\nenter the value:");
scanf("%d",&val);
temp2=(node *)malloc(sizeof(node));
temp2->data=val;
temp2->link=NULL;
if(head2==NULL)
{
head2=temp2;
}
else
{
curr2->link=temp2;
}
curr2=temp2;
}
while(curr1->link!=NULL)
{
curr1=curr1->link;
}
curr1->link=head2;
curr1=head1;
temp2=head1->link;
while(curr1!=NULL)
{
while(temp2!=NULL)
{
if(curr1->data==temp2->data)
{
printf("\n The value is: %d",curr1->data);
}
temp2=temp2->link;
}
curr1=curr1->link;
temp2=curr1->link;
}
}
void unio()
{
node *curr1,*temp1,*curr2,*temp2,*head1=NULL,*head2=NULL;
int no,i,val,c1=0,c2=0,f=0;
printf("\nCreate 1st linklist:");
printf("\nenter the no of node:");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\nenter the value:");
scanf("%d",&val);
temp1=(node *)malloc(sizeof(node));
temp1->data=val;
temp1->link=NULL;
if(head1==NULL)
{
head1=temp1;
}
else
{
curr1->link=temp1;
}
curr1=temp1;
}
printf("\nCreate 2nd linklist:");
}
}
}