#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2;
void main()
{
struct node *temp,*q;
int n,i,x;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
q=start1;
while(q->link!=NULL)
{
//concatenate two linked list
q=q->link;
}
q->link=start2;
printf("\n After concatenate linked list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
getch();
}
#include<conio.h>
#include<process.h>
#include<string.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2;
void main()
{
struct node *temp,*q;
int n,i,x;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
q=start1;
while(q->link!=NULL)
{
//concatenate two linked list
q=q->link;
}
q->link=start2;
printf("\n After concatenate linked list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
getch();
}