//PROGRAM TO PERFORM LINEAR SEARCH
//Downloaded from www.c4cprog.co.nr
#include<conio.h>
void calc(int a[],int x,int n)
{
int k=0,i; F
for(i=0;i<n;i++)
if(a[i]==x)
{
printf("\n\nElement is found at Position : %d ",i+1);
k++;
}
if(k==0)
printf("\nElemnt NOT FOUND !!!");
}
void main()
{
int x,a[100],i,n,k;
clrscr();
printf("Enter Limit :");
scanf("%d",&n);
printf("\n\nEnter Array :\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("\nEnter Element To Be Searched For :");
scanf("%d",&x);
calc(a,x,n);
getch();
}
Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]
Linear Search
Click Here To Download C File Of This Program
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment