Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Taking the absolute value of the modulo operation returns a positive value.:

Code Block
bgColor#FFCCCC
int insert(int index, int *list, int size, int value) {
  if (size != 0) {
    index = abs((index + 1) % size);
    list[index] = value;
    return index;
  }
  else {
    return -1;
  }
}

...