Write a program to calculate transpose of a matrix.
object Demo2
{
def main(args:Array[String])
{
print("How many Rows = ")
var rows = scala.io.StdIn.readInt()
print("How many Column = ")
var col = scala.io.StdIn.readInt()
var matrix = Array.ofDimInt
var arr = Array.ofDimInt
for(i<-0 to 3-1)
{
for(j<-0 to 3-1)
{
print("Enter Data for "+i+" of "+j+" = ")
matrix(i)(j) = scala.io.StdIn.readInt()
}
}
for(i<-0 to 3-1)
{
for(j<-0 to 3-1)
{
arr(i)(j) = matrix(j)(i)
}
}
for(i<-0 to 3-1)
{
for(j<-0 to 3-1)
{
print(arr(i)(j)+" ")
}
println()
}
}
}