Added count feature

This commit is contained in:
SF
2026-07-30 06:49:33 +00:00
parent dc5257ce84
commit 280758e7b5
4 changed files with 17 additions and 0 deletions
BIN
View File
Binary file not shown.
+14
View File
@@ -41,3 +41,17 @@ int search(int value)
return 0;
}
int count()
{
int count = 0;
Node *temp = head;
while (temp != NULL)
{
count++;
temp = temp->next;
}
return count;
}
+2
View File
@@ -1,3 +1,4 @@
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
@@ -11,5 +12,6 @@ typedef struct Node
void insert(int data);
void display();
int search(int value);
int count();
#endif
+1
View File
@@ -17,6 +17,7 @@ if (search(20))
{
printf("\nElement not found\n");
}
printf("Total nodes = %d\n", count());
return 0;
}