Code:
#include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define N 10
int search (int a [], int n, int key){
int b;
for(b=0; b<n; b++){
if (key==*(a+b)){
return TRUE;}
/*search for values with pointer*/
}
else
return FALSE;
}
int main()
{
int *ptr, k, j=9;
int array[]={10, 20, 13, 32, 50, 25, 40, 49, 11, 12};
k=10;
search(array[],j,10);
if (search(array[],j,10)==TRUE){
printf ("%d does exist", k)}
else if(search(array[],j,10)==FALSE){
printf ("%d does not exist", k)}
k=145;
search(array[],j,145);
if (search(array[],j,145)==TRUE){
printf ("%d does exist", k)}
else if(search(array[],j,145)==FALSE){
printf ("%d does not exist", k)}
k=15;
search(array[],j,15);
if (search(array[],j,15)==TRUE){
printf ("%d does exist", k)}
else if(search(array[],j,15)==FALSE){
printf ("%d does not exist", k)}
k=11;
search(array[],j,11);
if (search(array[],j,11)==TRUE){
printf ("%d does exist", k)}
else if(search(array[],j,11)==FALSE){
printf ("%d does not exist", k)} /*run function with values*/
system("PAUSE");
}