// #include #define SIZE 5 // Searching for the value below #define TO_FIND 57 char search (char tab[], char size, char to_find) { char low = 0, high = size-1, i; while (high >= low) { i = (high+low) / 2; if (tab[i] == to_find) return i; if (tab[i] > to_find) high = i-1; if (tab[i] < to_find) low = i+1; } return (-1); } int main () { char tab[SIZE] = {0, 18, 23, 57, 120}; char res = search(tab, SIZE, TO_FIND); // printf("%d\n", res); return res; }