Showing posts with label LINEAR SEARCH. Show all posts
Showing posts with label LINEAR SEARCH. Show all posts

Saturday, December 5, 2009

LINEAR SEARCH

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();
}

Read more...

  © Blogger template Coozie by Ourblogtemplates.com 2008

Back to TOP