-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete_Node_beginning_of_Doubly_Linked_List.c
More file actions
80 lines (73 loc) · 1.69 KB
/
Delete_Node_beginning_of_Doubly_Linked_List.c
File metadata and controls
80 lines (73 loc) · 1.69 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *prev, *next;
};
struct node *head = NULL, *newnode = NULL, *temp = NULL;
void create_linked_list();
void display_list();
void del_node_beginning_of_doubly_linked_list();
int main()
{
create_linked_list();
display_list();
del_node_beginning_of_doubly_linked_list();
display_list();
return 0;
}
void create_linked_list()
{
int choice = 1;
while(choice==1)
{
newnode = (struct node *)malloc(sizeof(struct node));
if(newnode==NULL)
printf("Memory Not allocate.");
else
{
printf("Enter data of node\n");
scanf("%d", &newnode->data);
newnode->prev = newnode->next = NULL;
if(head==NULL)
head = temp = newnode;
else
{
temp->next = newnode;
newnode->prev = temp;
temp = newnode;
}
printf("Do you want to insert another node in Linked List? if yes press 1 else press 0\n");
scanf("%d", &choice);
}
}
}
void display_list()
{
if(head==NULL)
printf("Linked List is Empty.");
else
{
temp = head;
printf("\nThe elements of Linked List are\n");
while(temp!=NULL)
{
printf("%d ", temp->data);
temp = temp->next;
}
}
}
void del_node_beginning_of_doubly_linked_list()
{
if(head==NULL)
printf("Linked List is Empty.");
else
{
temp = head;
head = head->next;
printf("\nThe Deleted Node element is: %d\n", temp->data);
free(temp);
temp = NULL;
}
}