skip to main
|
skip to sidebar
The linear search program is type of searching in data structure.This program is used to search the particular name or numbers linearly.
void main()
{
int a[100],n,i,l;
clrscr();
printf( " \n\n\n\n\t\t LINEAR SEARCH ");
printf("\nENTER THE NUMBER OF VALUE:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n\t\tENTER THE NUMBER:",i+1);
scanf("%d",&a[i]);
}
printf("\n\t THE LINEAR SEARCH IS ");
scanf("%d",&l);
for(i=1;i<=n;i++)
{
if(a[i]==l)
{
printf("\n\n\t THE GIVEN VALUE IS FOUND ");
printf("\n\n\t THE LINEAR POSTION IS:%d",i);
l=1;
break;
}
}
if(l!=1)
{
printf(" THE GIVEN VALUE IS NOT FOUND ");
}
getch();
}
You may also like:
{ 0 comments ... read them below or add one }
Post a Comment