Thursday, July 30, 2009

linear search using c language

//program to findwhether the numbber is in given list
#include
#include
void main()
{
int a[10],n,i,j,count=0,n1;
clrscr();

printf("\nEnter the num of elements in the array:");
scanf("%d",&n);
printf("\nEnter the elements into the array");
flushall();
for(i=0;i scanf("%d",&a[i]);
printf("\nEnter the number to be searched in the list:");
scanf("%d",&n1);
for(i=0;i {
if(a[i]==n1)
{ count++;
break;
}
}
if(count!=0)
printf("\nthe number %d is in given list",n1);
else
printf("\nthe number %d is not in given list",n1);
getch();
}

No comments:

Post a Comment