///search a number using an arary using linear search.
int main()
{
int ara[100],i,key,n,loc,ck;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&ara[i]);
scanf("%d",&key);
ck=0;
for(i=0;i<n;i++){
if (ara[i]==key){
ck=1;
loc=i+1;
break;
}
}
if (ck==1)
printf("%d",loc);
else
printf("No");
return 0;
}
No comments:
Post a Comment