diff --git a/linkedlist b/linkedlist index b33d890..94affb9 100755 Binary files a/linkedlist and b/linkedlist differ diff --git a/linkedlist.c b/linkedlist.c index 1759bbb..6ba7cc7 100644 --- a/linkedlist.c +++ b/linkedlist.c @@ -24,3 +24,20 @@ void display() temp = temp->next; } } + +int search(int value) +{ + Node *temp = head; + + while (temp != NULL) + { + if (temp->data == value) + { + return 1; + } + + temp = temp->next; + } + + return 0; +} diff --git a/linkedlist.h b/linkedlist.h index ec530c5..9582cc6 100644 --- a/linkedlist.h +++ b/linkedlist.h @@ -10,5 +10,6 @@ typedef struct Node void insert(int data); void display(); +int search(int value); #endif diff --git a/main.c b/main.c index 1709bde..a3d92ae 100644 --- a/main.c +++ b/main.c @@ -9,5 +9,14 @@ int main() display(); +if (search(20)) + { + printf("\nElement found\n"); + } + else + { + printf("\nElement not found\n"); + } + return 0; }