Im confused on how to write the last 5 numbers in an array into binary. I know how to convert in general just keep diving by 2 and write out the remainder until the end but trying to transfer it into code is difficult. i_array is just an element of 100 numbers, NUM_TEST_ELEMENTS = 100. I tried attempting the code all the way at the bottom at step 7 but running it I can never get an output to print no matter where I put the print statement. Ignore the indent error it could not copy and paste correctly. I don't know how to properly write the code to do it and asking for any pointers on how to do it as I want to learn but don't know where to start.
int main(int argc, char **argv) {
  /* Local variables */
  float f_array[NUM_TEST_ELEMENTS];
  int i_array[NUM_TEST_ELEMENTS], i, j, temp;
  int hist_array[10];
  /* Step #1 - read in the float numbers to process */
  for (i = 0; i < NUM_TEST_ELEMENTS; i++) {
    scanf("%f", &f_array[i]);
  }
  for (i = 0; i < NUM_TEST_ELEMENTS; i++) {
    if (i % 2 == 0) {
      if (f_array[i] > 50) {
        f_array[i] *= 0.78;
      } else {
        f_array[i] *= 1.04;
      }
    }
    if (i % 2 != 0) {
      if (f_array[i] > 50) {
        f_array[i] *= 0.92;
      } else {
        f_array[i] *= 1.15;
      }
    }
  }
  void round311 (float f_array[], int i_array[]) {
    for (i = 0; i < NUM_TEST_ELEMENTS; i++) {
      i_array[i] = (int)(f_array[i] + 0.5);
    }
  }
  // Calling the function to Convert f_array into integers into i_array
  round311(f_array, i_array);
  void printfloatArr311(float f_array[]) {
    for (i = 0; i < NUM_TEST_ELEMENTS; i++) {
      printf("%.2f,", f_array[i]);
    }
  }
  printf("Testing printfloatArr311 (floats): ");
  printfloatArr311(f_array);
  printf("\n\n");
  //Prints out i_array 
  void printIntArr311(int i_array[]) {
    for (i=0; i<NUM_TEST_ELEMENTS; i++) {
      printf("%d, ", i_array[i]);
    }
  }
  printf("Testing printIntArr311 (integers): ");
  printIntArr311(i_array);
  printf("\n\n");
  void bubbleSort311(int i_array[]) {
    for (i = 0; i < NUM_TEST_ELEMENTS; i++) {
      for (j = 0; j < NUM_TEST_ELEMENTS - i - 1; j++) {
        if (i_array[j] > i_array[j+1]) {
          temp = i_array[j];
          i_array[j] = i_array[j+1];
          i_array[j+1] = temp;
        }
      }
    }
  }
  printf("Testing bubbleSort311 (integers): ");
  bubbleSort311(i_array);
  printIntArr311(i_array);
  printf("\n\n");
  /* Step #7 - print out the last 5 values of the integer array in binary. */
  printf("Testing toBinary:\n");
  for (i = NUM_TEST_ELEMENTS - 6; i < NUM_TEST_ELEMENTS; i++) {
    int toBinary(int i_array[]) {
      int extarr[8];
      j = 0;
      while(i_array[i] > 0) {
        extarr[i] = i_array[i] % 2;
        i_array[i] = i_array[i] / 2;
        j++;
      }
      printf(extarr);
    }
  }
  printf("\n\n");
}
Im trying to get an output to look like below with the space between every fourth bit.
Testing toBinary:
0100 1111
0101 0011
0101 0101
0101 0111
0101 1010
0101 1100
 
    