Write a C program to search for an element using Linear Search
#include < stdio.h>
int main()
{
int array[100], key, c, number;
printf("Enter the number of elements in array\n");
scanf("%d",&number);
printf("Enter %d numbers\n", number);
for ( c = 0 ; c < number ; c++ )
scanf("%d",&array[c]);
printf("Enter the number to search\n");
scanf("%d",&key);
for ( c = 0 ; c < number ; c++ )
{
if ( array[c] == key )
/* if required element found */
{
printf("%d is present at location %d.\n", key, c+1);
break;
}
}
if ( c == number )
printf("%d is not present in array.\n", search);
return 0;
}