Compare commits

..
3 Commits
Author SHA1 Message Date
SF c0a432b2e7 Added count feature 2026-07-29 12:04:10 +00:00
SF 4d9c36b471 Added search feature 2026-07-29 11:55:22 +00:00
SF 9f333aa21c Added basic linked list 2026-07-29 11:35:17 +00:00
4 changed files with 34 additions and 37 deletions
BIN
View File
Binary file not shown.
+7 -6
View File
@@ -2,8 +2,10 @@
#include<stdlib.h>
#include "linkedlist.h"
Node *head = NULL;
void insert(int data)
{
Node *newNode = malloc(sizeof(Node));
@@ -14,6 +16,7 @@ void insert(int data)
head = newNode;
}
void display()
{
Node *temp=head;
@@ -25,26 +28,24 @@ void display()
}
}
Node *search(int value)
int search(int value)
{
Node *temp = head;
while(temp != NULL)
{
if(temp->data == value)
{
return temp;
}
return 1;
temp = temp->next;
}
return NULL;
return 0;
}
int count()
{
int count = 0;
Node *temp = head;
while(temp != NULL)
+2 -2
View File
@@ -1,4 +1,3 @@
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
@@ -9,9 +8,10 @@ typedef struct Node
}Node;
void insert(int data);
void display();
Node *search(int value);
int search(int value);
int count();
#endif
+9 -13
View File
@@ -1,33 +1,29 @@
#include<stdio.h>
#include "linkedlist.h"
int main()
{
insert(10);
insert(20);
insert(30);
printf("Linked List: ");
display();
Node *result = search(20);
if (result != NULL)
int result = search(20);
if(result)
{
printf("\n the Element found: %d\n", result->data);
printf("\nElement found");
}
else
{
printf("\n the Element not found\n");
printf("\nElement not found");
}
printf("Total nodes = %d\n", count());
printf("Count operation completes.\n");
printf("\nThis is Main Branch\n");
printf("\nThis is Feature Branch\n");
printf("\nTotal nodes = %d", count());
return 0;
}