#include<stdio.h>
#include<conio.h>
int LSearch(int[],int,int);
main()
{
int search=0,n=0,i=0,j=0,t=0,a[100],result=0;
clrscr();
printf("\n Enter How Many Numbers :");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("\n Enter Search Element :");
scanf("%d",&search);
result=LSearch(a,n,search);
if(result==-1)
printf("\n Element Not Found");
else
printf("%d Found At %d Position",search,result+1);
getch();
}
int LSearch(int a[],int n,int s)
{
int i;
for(i=0;i,n;i++)
{
if(a[i]==s)
return i;
}
}
#include<conio.h>
int LSearch(int[],int,int);
main()
{
int search=0,n=0,i=0,j=0,t=0,a[100],result=0;
clrscr();
printf("\n Enter How Many Numbers :");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("\n Enter Search Element :");
scanf("%d",&search);
result=LSearch(a,n,search);
if(result==-1)
printf("\n Element Not Found");
else
printf("%d Found At %d Position",search,result+1);
getch();
}
int LSearch(int a[],int n,int s)
{
int i;
for(i=0;i,n;i++)
{
if(a[i]==s)
return i;
}
}
No comments:
Post a Comment