C Program for Linear search
#include<conio.h>#include<stdio.h>
main()
{
int a[20], n,i,k, flag=0,loc;
printf("Enter the size of Array: ");
scanf("%d",&n);
printf("Enter the Numbers: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter Searching Element: ");
scanf("%d",&k);
for(i=0;i<n;i++)
{
if(a[i]==k)
{
loc=i+1;
flag=1;
break;
}
}
if(flag==1)
printf("The element is found at location %d",loc);
else
printf("Element is not found");
}