Added basic linked list

This commit is contained in:
SF
2026-07-29 11:35:17 +00:00
parent 28364c2f27
commit 9f333aa21c
4 changed files with 59 additions and 0 deletions
Executable
BIN
View File
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
#include<stdio.h>
#include<stdlib.h>
#include "linkedlist.h"
Node *head = NULL;
void insert(int data)
{
Node *newNode = malloc(sizeof(Node));
newNode->data = data;
newNode->next = head;
head = newNode;
}
void display()
{
Node *temp=head;
while(temp!=NULL)
{
printf("%d ",temp->data);
temp=temp->next;
}
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
typedef struct Node
{
int data;
struct Node *next;
}Node;
void insert(int data);
void display();
#endif
+15
View File
@@ -0,0 +1,15 @@
#include<stdio.h>
#include "linkedlist.h"
int main()
{
insert(10);
insert(20);
insert(30);
display();
return 0;
}