From 38be7d46efd80fcd86df616dd2334fd5a436f4f1 Mon Sep 17 00:00:00 2001 From: Sahil Sayani <72189595+SahilSayani@users.noreply.github.com> Date: Thu, 7 Oct 2021 15:11:14 +0530 Subject: [PATCH] linkedList in C created --- C/linkedList/README.md | 1 + C/linkedList/linkedList.c | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 C/linkedList/README.md create mode 100644 C/linkedList/linkedList.c diff --git a/C/linkedList/README.md b/C/linkedList/README.md new file mode 100644 index 0000000..1f00375 --- /dev/null +++ b/C/linkedList/README.md @@ -0,0 +1 @@ +program to make linked list diff --git a/C/linkedList/linkedList.c b/C/linkedList/linkedList.c new file mode 100644 index 0000000..8f43e47 --- /dev/null +++ b/C/linkedList/linkedList.c @@ -0,0 +1,40 @@ +#include +#include + +struct node{ +int data; +struct node*next; +}; +void printLL(struct node*p){ + while(p!=NULL){ + printf("%d",p->data); + p=p->next; + } +} + +int main() +{ + // node init + struct node*head; + struct node*one; + struct node*two; + struct node*three; + // malloc + one=malloc(sizeof(struct node)); + two=malloc(sizeof(struct node)); + three=malloc(sizeof(struct node)); + // assignment and link + + one->data=1; + one->next=two; + + two->data=2; + two->next=three; + + three->data=3; + three->next=NULL; + + //save head as first node; + head=one; + return 0; +} \ No newline at end of file