Write an R program to calculate the sum of the diagonal elements of a matrix.
EasyProblem Statement
Write an R program to calculate the sum of the diagonal elements of a matrix.
Sample Input
Matrix: [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9
Sample Output
Diagonal Sum: 15
Limits
Time: 2s · Memory: 256 MB