modified search feature

This commit is contained in:
Shifa
2026-07-30 10:07:05 +00:00
parent 280758e7b5
commit 6c9f757c62
4 changed files with 10 additions and 7 deletions
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -25,7 +25,7 @@ void display()
}
}
int search(int value)
Node *search(int value)
{
Node *temp = head;
@@ -33,13 +33,13 @@ int search(int value)
{
if (temp->data == value)
{
return 1;
return temp;
}
temp = temp->next;
}
return 0;
return NULL;
}
int count()
+1 -1
View File
@@ -11,7 +11,7 @@ typedef struct Node
void insert(int data);
void display();
int search(int value);
Node *search(int value);
int count();
#endif
+5 -2
View File
@@ -6,17 +6,20 @@ int main()
insert(10);
insert(20);
insert(30);
printf("Linked List: ");
display();
if (search(20))
Node *result = search(20);
if (result != NULL)
{
printf("\nElement found\n");
printf("\nElement found: %d\n", result->data);
}
else
{
printf("\nElement not found\n");
}
printf("Total nodes = %d\n", count());
return 0;