C Program for LINEAR SEARCH

Linear search is also called as sequential search. All the elements need not be in sorted order like binary search. The program for linear search is written in C language.

Check the other linear search articles given below

  • Linear Search Algorithm With Example
  • C Program to Find an Element Using Linear Search

Linear Search in C

include

int main()
{
int a[10], i, item,n;
printf(“\nEnter number of elements of an array:\n”);
scanf(“%d”,&n);
printf(“\nEnter elements: \n”);
for (i=0; i 9)
printf(“\nItem does not exist.”);
return 0;
}

Output for Linear Search in C:
Enter number of elements of an array:
8

Enter elements:
2 3 5 7 8 6 4 1

Enter item to search: 1

Item found at location 8

Leave a Reply

Your email address will not be published.