File tree 1 file changed +49
-0
lines changed
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ struct node
5
+ {
6
+
7
+ int data ;
8
+ struct node * next ;
9
+ };
10
+
11
+ void display (struct node * ptr )
12
+ {
13
+
14
+ while (ptr != NULL )
15
+ {
16
+ printf ("%d\n" , ptr -> data );
17
+ ptr = ptr -> next ;
18
+ }
19
+ }
20
+
21
+ int main ()
22
+ {
23
+
24
+ struct node * head ;
25
+ struct node * first ;
26
+ struct node * secound ;
27
+ struct node * third ;
28
+
29
+ head = (struct node * )malloc (sizeof (struct node ));
30
+ first = (struct node * )malloc (sizeof (struct node ));
31
+ secound = (struct node * )malloc (sizeof (struct node ));
32
+ third = (struct node * )malloc (sizeof (struct node ));
33
+
34
+ head -> data = 45 ;
35
+ head -> next = first ;
36
+
37
+ first -> data = 50 ;
38
+ first -> next = secound ;
39
+
40
+ secound -> data = 60 ;
41
+ secound -> next = third ;
42
+
43
+ third -> data = 80 ;
44
+ third -> next = NULL ;
45
+
46
+ display (head );
47
+
48
+ return 0 ;
49
+ }
You can’t perform that action at this time.
0 commit comments