#include< stdio.h>
#include < conio.h>
//global declaration of varaible
int a[20], i,n, s,found=0;
void main()
{
printf("\nEnter Total Number of Elements =");
scanf("%d",&n);
//enter array elements
for(i=0;i < n;i=i+1)
{
scanf("%d",&a[i]);
}
printf("\nEnter Element to be Searched = ");
scanf("%d",&s);
//Search Element Using Linear Search
for(i=0;i < n;i=i+1)
{
if(a[i]= =s)
{
printf("\nElement %d found at postion %d.", s,i+1);
found=1;
break;
}
}
if (found= =0)
{
printf("Element Not Found");
}
getch();
}
Thursday, May 27, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment