Find sum of lower triangular matrix elements - C

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

Solution:

lower 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("\nLower Triangular Elements :\n");
     for(i=0;i<=2;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 Lower Triangular Elements = %d",s);
     return 0;
}


Output:

sum lower triangular matrix