Hi I'm writing a menu driven array with 50 randomly generated integers. In the program I am suppose to search for numbers in the array and print the number and location of the number in the array. I have most of the program finished, however when I input an incorrect integer to find in the array I also need to show that the number is incorrect and the greatest number less than the target (w/ index location) and the smallest value greater than the target (w/ index location).

So far I've written a function where it finds just the next closest number to the target but I don't know how to change it so that it can differentiate between the greatest number less than target and smallest number greater than target.

```
void checkNum(int numary[], int target)
{
int closestNumber = 0;
int closestProximity = 0;
int newProximity = 0;
int location = 0;
closestNumber = numary[0];
if (closestNumber < target)
{
closestProximity = target - closestNumber;
}
else
{
closestProximity = closestNumber - target;
}
// printf("\n%d\n", closestProximity);
for (int i = 0; i < 50; i++)
{
if(numary[i] < target)
{
newProximity = target - numary[i];
}
else
{
newProximity = numary[i] - target;
}
if (newProximity < closestProximity)
{
closestProximity = newProximity;
closestNumber = numary[i];
location = i;
}
}
printf("\nClosest Value Before: %d at location %d", closestNumber, location);
// printf("\nCloset Value After: %d at location %d", closestNumberA, locationA);
}
```