object MatrixSize extends App {
val matrix = Array(
Array(2, 0, 5, 9),
Array(0, 4, 0, 3),
Array(0, 8, 0, 1)
)
// Get the number of rows
val rows = matrix.length
// Get the number of columns
val columns = matrix(0).length
val totalCells = rows * columns
println(s"Matrix size: $rows rows x $columns columns")
println(s"Total Cells: $totalCells")
}
/*
run:
Matrix size: 3 rows x 4 columns
Total Cells: 12
*/