Q:

Identify the indexing errors in the following code

0

Identify the indexing errors in the following code:

constexpr size_t array_size = 10;
int ia[array_size];
for (size_t ix = 1; ix <= array_size; ++ix)
ia[ix] = ix;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

int main() {
  constexpr size_t array_size = 10;
  int ia[array_size];  // index from `0` to `array_size - 1`
  //for (size_t ix = 1; ix <= array_size; ++ix)
  //  ia[ix] = ix;
  for (size_t ix = 0; ix < array_size; ++ix)
    ia[ix] = ix + 1;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now