You are on page 1of 2

PCS 251 Practical Session

Note: Students have to add a signature line at each program execution; You
need to print your name at first line in all the programs; The output must
contain your name in the first line.

Questions on Two Dimensional Array


1. Develop a program to print transpose of a matrix of order M x N accepted from the user.
Sample:
Input: A=[ 1 2 3 Output: AT=[ 1 4 7
4 5 6 2 5 8
7 8 9] 3 6 9]

2. Develop a program to find the sum of diagonal elements of a matrix of order MxN
accepted from the user.

Input: P= [ 1 4 7
2 6 5
3 9 8 ]

Indicates Principal Diagonal Indicates Secondary Diagonal


Output: Sum of Principal Diagonal: 15
Sum of Secondary Diagonal: 16
3. Develop a program test whether a given matrix of order MxN is an upper - triangular
matrix or not. An upper triangular Matrix is one in which all the elements below its
principal diagonal are 0.

Input: Q= [ 1 5 -8 Output: Matrix Q is upper triangular matrix


0 2 -1
0 0 3]
4. Develop a program to find product of two matrices of order M x N and P x Q accepted
from the user.
Sample:
Input: A= [ 12 B= [ 1 1 Output: C=AXB= [ 5 5
34] 2 2] 11 11 ]

5. Develop a program to find the biggest element of a given matrix of order M x N accepted
from the user.

Input: M= [ -11 -3 -7
-25 -9 -77
-99 -33 -87 ]

Output: -3 is the biggest element of the matrix

You might also like