Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Find the sum of elements above the main diagonal in a 3x3 matrix {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}.

Medium

Problem 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; }
Log in or sign up to run or submit your code.Log inSign up
Input
Matrix:
 1 2 3
 4 5 6
 7 8 9
Expected Output
Sum above main diagonal: 11