fork download
  1. #include <stdio.h>
  2.  
  3. void f (int Y[10] , int x) {
  4. int j, k;
  5. int i= 0; j = 9;
  6. do {
  7. k = (i+ j) / 2;
  8. if( Y[k] < x)
  9. i = k;
  10. else
  11. j = k;
  12. } while ((Y[k] != x) && (i < j));
  13. if(Y[k] == x)
  14. printf(" x is in the array ");
  15. else
  16. printf(" x is not in the array ");
  17. }
  18.  
  19. int main(void) {
  20. int *Y;
  21. int B[]={1,3,5,7,9,11,13,15,17,19};
  22. Y = B;
  23. f(Y,0);
  24. return 0;
  25. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
 x is not in the array