Find the sum of elements above the main diagonal in a 3x3 matrix {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}.
MediumProblem Statement
Find the sum of elements above the main diagonal in a 3x3 matrix {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}.
Sample Input
Matrix: 1 2 3 4 5 6 7 8 9
Sample Output
Sum above main diagonal: 11
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
int sumAboveDiagonal(int matrix[3][3]) {
// Your code here
}
int main() {
int matrix[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
printf("Sum above main diagonal: %d\n", sumAboveDiagonal(matrix));
return 0;
}
Input
Matrix: 1 2 3 4 5 6 7 8 9
Expected Output
Sum above main diagonal: 11