Skip to content

Commit

Permalink
Merge pull request #374 from iceybubble/master
Browse files Browse the repository at this point in the history
Create LinkList.c
  • Loading branch information
Kavya-24 authored Oct 5, 2024
2 parents 51c0450 + 45ad181 commit 1f613b0
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 1f613b0

Please sign in to comment.