#include <stdio.h>
#include <stdbool.h>
bool search(const int a[],int n,int key);
int main()
{
int a[10]={1,3,5,8,9,12,46,78,4,10},key;
scanf("%d",&key);
if(search(a,10,key)==true)
printf("key is in the array");
else
printf("key isn't in the arrary");
return 0;
}
bool search(const int a[],int n,int key)
{
const int *p;
int c=0;
for(p=a;p<a+n;p++)
{
if(key==*p)
c=1;
}
if(c==1)
return true;
else
return false;
}
#include <stdbool.h>
bool search(const int a[],int n,int key);
int main()
{
int a[10]={1,3,5,8,9,12,46,78,4,10},key;
scanf("%d",&key);
if(search(a,10,key)==true)
printf("key is in the array");
else
printf("key isn't in the arrary");
return 0;
}
bool search(const int a[],int n,int key)
{
const int *p;
int c=0;
for(p=a;p<a+n;p++)
{
if(key==*p)
c=1;
}
if(c==1)
return true;
else
return false;
}