-
Notifications
You must be signed in to change notification settings - Fork 0
/
l6q1.c
48 lines (46 loc) · 911 Bytes
/
l6q1.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
#include <stdio.h>
#include<malloc.h>
struct node61
{
int data;
struct node61 *next,*prev;
};
void create61(struct node61 **h)
{
int n;
struct node61 *curr,*tail;
printf("ENTER THE NUMBER OF NODES : ");
scanf("%d",&n);
printf("Enter the elements : ");
for(int i=0;i<n;i++)
{
curr = malloc(sizeof(struct node61));
curr->next = curr->prev = NULL;
scanf("%d",&curr->data);
if( *h == NULL )
{
*h = tail = curr;
}
else
{
curr->prev = tail;
tail->next = curr;
tail = curr;
}
}
}
void display61(struct node61 *h)
{
while(h != NULL)
{
printf("%d -> ",h->data);
h =h->next;
}
}
int l6q1()
{
struct node61 *head = NULL;
create61(&head);
display61(head);
return 0;
}