Skip to content

Commit 2aac00c

Browse files
committed
initial commit
1 parent 1d59ef1 commit 2aac00c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

LinkedList.c

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

0 commit comments

Comments
 (0)