MENU
Question -

Write a program to input any matrix and print both diagonal values of the matrix.



Answer -

Import random
m = input (“Enter the number of rows”)
n = input (“Enter the number of columns”)
a = [[random.random () for row in range (m)] for cal in mange (n)]
if i in range (m):
for j in range (n):
a[i][j] = input ()
print “First diagonal”
for i in range (m):
print a[i][j], ‘\t’
k = m – 1
print “second diagonal”
for j in range (m):
print a[j][k], ‘\t’
k- = 1
else:
print “Diagonal values are not possible”

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×