Binary Search Non recursive

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> int main(void) { printf("Hello World!\n"); int arr[10] = {1,2,3,4,5,6,7}; int se = -5; int high,mid, low = 0; high = 6; while(low<=high){ mid = high + low / 2; if (arr[mid] == se){ printf("element found at index %d",mid); return 0; }else if (arr[mid] < se){ low = mid + 1; }else{ high = mid - 1; } } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines