2D Array
2D Array
(Total 15 questions)
SL Problem statement Difficulty
levels
1. WAP that will take n integers into a sqrt(n) by sqrt(n) array (2D) and show them as *
traditional matrix view.
2. WAP that will take (m x n) integers into a m by n array (2D) and print them both row-wise *
and column-wise.
3. WAP that will take inputs of a 3 by 3 matrix into a 2D array. Now find the determinant of *
this matrix. http://www.mathsisfun.com/algebra/matrix-determinant.html
5. WAP that will take the size of an identity matrix from the user and generate the identity *
matrix into a 2D array. Finally display it. Reference:http://en.wikipedia.org/wiki/Identity_matrix
6. WAP that will take inputs of two m x n sized matrix into two 2D array, suppose A and B. *
Now do C = A + B. Finally display all the elements from matrix / 2D array C.
7. WAP that will take inputs of two 3 x 3 sized matrix into two 2D array, suppose A and B. Now ***
do C = A * B (multiplication). Finally display all the elements from matrix / 2D array C.
9. WAP that will take (n x n) integer inputs into a square matrix of dimension n (where n must **
be an odd number). Then calculate sum of the integers at first row, last row and two
diagonals without overlap. Please see the sample input-output.
7 23
1111111
1111111
1111111
1111111
1111111
1111111
1111111
10. WAP that will take (n x n) integer inputs into a square matrix of dimension n (where n **
must be an odd number). Then calculate sum of the integers based on following position
pattern (consider only the boxed position during the sum). Please see the input-output.
7 25
1111111
1111111
1111111
1111111
1111111
1111111
1111111
11. WAP that will take (n x n) integer inputs into a square matrix of dimension n (where n **
must be an odd number). Then calculate sum of the integers based on following position
pattern (consider only the boxed position during the sum). Please see the input-output.
7 33
1111111
1111111
1111111
1111111
1111111
1111111
1111111
12. WAP that will take (m x n) integer inputs into a matrix of dimension m x n. Now reverse **
that matrix within itself and display it. Reversal means swap 1st column with the nth
column, swap 2nd column with the (n-1)th column and so on…
13. WAP that will take (n x n) integer inputs into a square matrix of dimension n. Now **
determine whether the matrix is symmetric or not.
Reference: http://en.wikipedia.org/wiki/Symmetric_matrix
14. WAP that will take (m x n) positive integer inputs into a matrix of dimension m x n. Now ***
replace all the duplicate integers by -1 in that matrix. Finally display it.