-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.c
43 lines (39 loc) · 900 Bytes
/
1.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
#include <stdio.h>
#include <stdlib.h>
struct node{
int data;
struct node *next, *prev;
}*head;
void createlist(int n){
struct node *newnode, *temp;
head = (struct node*) malloc(sizeof(struct node));
printf("Enter the value of first node\n");
scanf("%d", &head->data);
head->next = NULL;
head->prev = NULL;
temp = head;
for(int i=1; i<n; i++){
newnode = (struct node*) malloc(sizeof(struct node));
printf("Enter node-%d data\n", i+1);
scanf("%d", &newnode->data);
newnode->next = NULL;
newnode->prev = temp;
temp->next=newnode;
temp = newnode;
}
}
void displaylist(){
struct node *temp;
temp=head;
printf("Display list\n");
while(temp!=NULL){
printf("%d\n", temp->data);
temp = temp->next;
}
}
int main()
{
createlist(4);
displaylist();
return 0;
}