Important Notice:

Print Elements of Upper Triangular Matrix

Print Elements of Upper Triangular Matrix

5 views 1 min read

Print Elements of Upper Triangular Matrix (Upper Triangular Matrix के Elements को प्रदर्शित करना) :-

Quetion-

Write an algorithm and flowchart to print the elements of the upper triangular matrix.

Upper Triangular Matrix के Elements को प्रदर्शित करने के लिए Algorithm और Flowchart लिखिए।

Example Input Matrix

 

0 1 2

-------------

0 | 1 2 3

1 | 4 5 6

2 | 7 8 9

 

Output (Upper Triangular Matrix)

 

1 2 3

0 5 6

0 0 9

 

Solution - Algorithm: Print Elements of Upper Triangular Matrix

Step 1: Start.

Step 2: Input the number of rows R and columns C.

Step 3: Input all matrix elements.

Step 4: Set i = 0.

Step 5: Repeat Steps 6 to 10 while i < R.

Step 6: Set j = 0.

Step 7: Repeat Steps 8 and 9 while j < C.

Step 8: If i ≤ j, display A[i][j]; otherwise display 0.

Step 9: Set j = j + 1.

Step 10: Set i = i + 1.

Step 11: Stop.

Logic / Working (कार्यप्रणाली) -

  • Matrix के प्रत्येक Row और Column को एक-एक करके Check करें। — Check each row and column of the matrix one by one.
  • यदि i ≤ j हो, तो A[i][j] को Print करें। — If i ≤ j, print A[i][j].
  • यदि i > j हो, तो 0 Print करें। — If i > j, print 0.
  • सभी Rows और Columns के लिए यही प्रक्रिया दोहराएँ। — Repeat the same process for all rows and columns.
  • अंत में Upper Triangular Matrix Display करें। — Finally, display the upper triangular matrix.

Related Notes