-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedlist1.c
60 lines (59 loc) · 1.16 KB
/
linkedlist1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *next;
};
struct node * createnode(){
struct node *newnode;
newnode=(struct node *)malloc(sizeof(struct node));
return (newnode);
}
struct node insertnode(struct node **s,int info){
struct node *temp,*p;
temp=createnode();
temp->next=NULL;
temp->data=info;
if(*s==NULL)
*s=temp;
else{
p=*s;
while(p->next!=NULL)
{
p=p->next;
}
p->next=temp;
}
}
struct node display(struct node **s)
{
struct node *p;
p=*s;
while(p!=NULL){
printf("%d ",p->data);
p=p->next;
}
}
int main()
{
int k,i=1;
struct node *head1=NULL,*head2=NULL,*head3=NULL;
while(i<=4){
printf("enter data for first polyomial-\n");
scanf("%d",&k);
insertnode(&head1,k);
i++;
}
i=0;
while(i<=4)
{
printf("enter data for second polynomial");
scanf("%d",&k);
insertnode(&head2,k);
i++;
}
display(&head1);
printf("\n");
display(&head2);
return 0;
}