Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Print All Diagonals of a given matrix

Objec­tive: Given two dimen­sional matrix, write an algo­rithm to print all the diag­o­nals of matrix.

Exam­ple:
Print All Diagonals of Matix 2

Approach:

We will solve this prob­lem in two parts. first half of diag­o­nals and sec­ond half of diagonals.

See the code for more under­stand­ing, its self explanatory.

Com­plete Code:

Out­put:

1
5 2
9 6 3
13 10 7 4
14 11 8
15 12
16

You may also like...