myusuf's answer is almost correct, but it doesn't always return the index of the first occurence. Here is my suggestion:
int bisection(int el, int* a, int n)
{
int i = 0;
while(i < n)
{
// search in range i (inclusive) to n (exclusive)
int mid = (i + n) / 2;
if (el == a[mid] && (mid == 0 || a[mid-1] < el))
return mid;
if (el <= a[mid])
n = mid;
else
i = mid + 1;
}
return -1;
}