C function to implement Linear Search in linked list:
struct NODE{
int INFO;
struct NODE *LINK;
};
void search_11( struct NODE *ptr, int IN)
{
while(ptr !=NULL && ptr-->INFO !=IN)
ptr =ptr-->LINK;
if (ptr-->INFO == IN)
printf(“Search successful”);
else
printf(“Search unsuccessful”);
}
Other form of C function:
struct NODE{
int INFO;
struct NODE *LINK;
};
int search_11 (struct NODE *ptr, int IN)
{
while(ptr !=NULL)
{
if(ptr-->INFO == IN)
return 1;
ptr = ptr->LINK;
}
return 0;
}