write a program to search or find the element in array by using linear search .

#include<stdio.h>
#include<conio.h>
int main()
{
int a[5]={10,20,30,40,50};
int i,key,flag=0;
printf("enter search key\n");
scanf("%d",&key);
for(i=0;i<5;i++)
{
if(key==a[i])
{
flag=1;
break;
}
}
if(flag==1)
printf("key is found\n");
else
printf("key is not found\n");
return 0;
}


Comments

Popular posts from this blog

write a program for insertion sort with example.