Help in printing out the fourth column in a 3x4 matrix

=
Last edited on
1
2
3
4
5
6
 for(int i = 0; i < rows; i++)
{
     for(int j = 0; j < cols; j++)
          cout << yData[i][j];
    }
}
Last edited on
s
Last edited on
not sure what ur trying to do? but that code prints every cell in the matrix based on its rows and cols
Try this:

1
2
for(int i = 0; i < rows; ++i)
    cout << matrix[i][cols - 1];


Just replace rows, cols, and matrix with the names you use in your program (or with 3 and 4).
Last edited on
Topic archived. No new replies allowed.