#include <stdio.h>
struct node
{
int data;
struct node *link;
};
struct node1
{
int data1;
struct node1 *next1;
};
struct node1* link1(int k)
{
int a,b,i;
struct node1 *current1;
struct node1 *previous1=0;
struct node1 *head1=0;
struct node1 *c1;
for( i=0;i<k;i++)
{
current1=(struct node1*)malloc(sizeof(struct node1 ));
if(head1==0)
{
head1=current1;
}
if(previous1!=0)
{
previous1->next1=current1;
}
printf("enter %d number",i);
scanf("%d",&a);
current1->data1=a;
current1->next1=0;
previous1=current1;
}
return head1;
}
int main()
{
int A,b,i,k,size1=3,p;
struct node
{
int data;
struct node *link;
};
struct node *current;
struct node *previous=0;
struct node *head=0;
struct node *c;
struct node *add;
struct node1 *Num1;
struct node1 *Num2;
printf("enter 1 linked \n");
Num1=link1(size1);
printf("second 2 linked\n");
Num2=link1(size1);
for (i=0;i<3;i++)
{
current=(struct node*)malloc(sizeof(struct node ));
if(head==0)
{
head=current;
}
if(previous!=0)
{
previous->link=current;
}
current->data=Num1->data1+Num2->data1;
current->link=0;
previous=current;
Num1=Num1->next1;
Num2=Num2->next1;
}
current=head;
for(;current!=0;)
{
printf("%d\n",current->data);
current=current->link;
}
}