Find sum of upper triangular matrix elements - C

Write a C program to find the sum of upper triangular elements of matrix.

Solution:

upper triangular

#include <stdio.h>
int main()
{
     int a[3][3],i,j,s=0;
     printf("Enter Elements for 3*3 Matrix:\n\n");
     for(i=0;i<=2;i++)
          for(j=0;j<=2;j++)
          {
               scanf("%d",&a[i][j]);
          }
     printf("\n3*3 Matrix :\n\n");
     for(i=0;i<=2;i++)
     {
          for(j=0;j<=2;j++)
          {
               printf("%d ",a[i][j]);
          }
          printf("\n");
     }
     printf("\nUpper Triangular Elements :\n\n");
     for(i=0;i<=1;i++)
     {
          for(j=0;j<=2;j++)
          {
               if(i<j)
               {
                    printf(" %d",a[i][j]);
                    s=s+a[i][j];
               }
          }
          printf("\n  ");
     }
     printf("\nSum of Upper Triangular Elements = %d",s);
     return 0;
}


Output:

sum upper triangular matrix