Skip to content

Commit

Permalink
Create LinlList.c
Browse files Browse the repository at this point in the history
Added a new program LinkList.c
  • Loading branch information
iceybubble authored Oct 3, 2024
1 parent 67ae9a2 commit 45ad181
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions C Language/LinlList.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};

void main()
{
struct node *p, *head;
int n, i;
printf("How many nodes to be created\n");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
if (i == 0)
{
head = (struct node *)malloc(sizeof(struct node));
p= head;
}
else
{
p->next = (struct node *)malloc(sizeof(struct node));
printf("Enter the value: ");
scanf("%d", &p->next->data);
}
p = p->next;
}
p->next = NULL;
p = head;
while (p->next != NULL)
{
printf("%d", p->data);
p = p->next;
}
}

0 comments on commit 45ad181

Please sign in to comment.