what if we want to print both the diagonal elements!!!!
2-d array for printing both the digonal elements of a matrix...
Collapse
X
-
Tags: None
-
Hi shikha tripathi and welcome to bytes.com!
What you're looking for is probably the concept of nested loops; meaning, you can put one loop inside another. Here, an example:
Code:int** matrix = ...; int m, n; for(m = 0; m < MATRIX_HEIGHT; m++) { for(n = 0; n < MATRIX_WIDTH; n++) { // access matrix[m][n] here } }
Comment