Efficiency of binary search and improvements
While loop termination

The while loop condition is:


while(!found) {



But when you find your answer, you already do a break.  Therefore, the while loop condition could just be:

while (1) {


But there's more.  This statement here is not quite right:


if( (min==max) &amp;&amp; (anArray[max]!=userNumber) )
    break;



First of all, it is possible that min could actually go beyond max.  For example, if originally min is 6, max is 7, and avg is 6, then it could be the case that max becomes 5 afterwards.  So you really need to check if min &gt; max and break when that happens.

Secondly, if min == max, there's no need to do an extra equality check and break.  You can just loop around one more time.

Putting that all together, I would actually remove that whole if statement and change your while loop to:

while (min &lt;= max) {
    avg = (min+max) / 2;
    if (anArray[avg] == userNumber) {
        found = true;
        break;
    }
    if (anArray[avg] &lt; userNumber)
        min = avg+1;
    else
        max = avg-1;
}


Unnecessary if

Notice I also removed the check for anArray[avg] &gt; userNumber because at that point, it wasn't equal or less than, so it had to be greater than.