-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_12_2.c
45 lines (42 loc) · 848 Bytes
/
a_12_2.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
#include<stdio.h>
#include<stdlib.h>
struct node{
int num;
struct node *next; //insertion at middle
}*n1,*n2,*n3,*n4;
struct node * insert(struct node*head){
struct node *n=head;
while(n->num!=4){
n=n->next;
}
printf("Enter Extra :\n");
struct node* ext;
scanf("%d",&ext->num);
ext->next=n->next;
n->next=ext;
return head;
}
int main(){
n1=(struct node*)malloc(sizeof(struct node));
n2=(struct node*)malloc(sizeof(struct node));
n3=(struct node*)malloc(sizeof(struct node));
n4=(struct node*)malloc(sizeof(struct node));
printf("Enter Data :\n");
scanf("%d%d%d%d",&n1->num,&n2->num,&n3->num,&n4->num);
n1->next=n2;
n2->next=n3;
n3->next=n4;
n4->next=NULL;
printf("Data is :\n");
struct node *n=n1;
while(n!=NULL){
printf("Num : %d\n",n->num);
n=n->next;
}
insert(n1);
n=n1;
while(n!=NULL){
printf("Num : %d\n",n->num);
n=n->next;
}
}