# Check50 is claiming that it's recieving an exit code of 0 rather than 1 (different scenario)

I know this question has been answered before (pset 3 "search": expected an exit code of 0, not 1), but I took a look at it, and it seems that the scenario in which the person asked the question is different from mine, while it gets the same results, namely in that the position and way the program runs is different. Is there a reason why this is occurring? Code below:

``````bool search(int value, int values[], int n)
{
//uses binary search to complete the problem
//sets up running midpoint value and other values to control program
int minimum = 0;
int maximum = n - 1;
int midpoint = minimum + ((minimum + maximum)/2);

for (int i = 0; i <= n; i++)
{

if (n <= 0)
{
return false;
}
else
{
//sets up how the program acts in the events of each case
//NOTE: If this happens, either you're lucky, or you deliberately set it up this way. Either way, good job! Partial credit to CS50's binary search video
if (values[midpoint] == value)
{
return true;
}
//NOTE: If the rest happens, you're not so lucky, but ah well
if (values[midpoint] > value)
{
maximum = maximum - 1;
midpoint = minimum + ((minimum + maximum)/2);
}
if (values[midpoint] < value)
{
minimum = minimum + 1;
midpoint = minimum + ((minimum + maximum)/2);
}

}

}

return false;
}
``````

UPDATE: I'm now only receiving this error now.

``````:( finds 42 in {40,41,42}
\ expected an exit code of 0, not 1
``````

• Worse. `int minimum = values[0];` sets what should be an array index to the content of an array element. `if (values > midpoint)` tries to compare the entire array to what should be the index for the middle of the section of array being tested. I could go on, but you need to take some time and really look at the code and think about what the code is really doing and what it should do. – Cliff B Jul 23 '16 at 6:06