educative.io

What's happening with other index

I was able to print the array at index 0, but not the values at indexes 1 and 2. When I saw your proposed solution, it doesn’t print indexes 1 and 2 either. So how could I do it?


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5119797780021248
Lesson: https://www.educative.io/collection/page/10370001/5119797780021248/5738940401188864

Hi @JNick

Here is the print function solution that is working fine.

void printmat(Matrix M)
{
  int i, j;
  printf("[\n");
  for (i=0; i<M.nrows; i++) {
    for (j=0; j<M.ncols; j++) {
      printf("%6.3f ", M.data[i*M.ncols + j]);
    }
    printf("\n");
  }
  printf("]\n\n");
}