diff --git a/linkedlist b/linkedlist index b33d890..b945c43 100755 Binary files a/linkedlist and b/linkedlist differ diff --git a/linkedlist.c b/linkedlist.c index 3ce9959..b409442 100644 --- a/linkedlist.c +++ b/linkedlist.c @@ -27,3 +27,17 @@ 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 aebcf1c..0ee14af 100644 --- a/linkedlist.h +++ b/linkedlist.h @@ -11,5 +11,6 @@ typedef struct Node void insert(int data); void display(); +int search(int value); #endif diff --git a/main.c b/main.c index 09c6f09..0b02371 100644 --- a/main.c +++ b/main.c @@ -11,5 +11,16 @@ int main() display(); + int result = search(20); + + if(result) + { + printf("\nElement found"); + } + else + { + printf("\nElement not found"); + } + return 0; }