#include<stdio.h>
#include<conio.h>
void main()
{
int row, col,row_t,col_t,sumAvb=0,sumBlw=0;
printf("Enter Row And Collum :");
scanf("%d%d", &row, &col);
col_t=col;
row_t=row;
int matrix[row_t][col_t];
for(row=1;row<=row_t;++row)
{
for(col=1;col<=col_t;++col)
{
printf("element[%d][%d]",row,col);
scanf("%d",&matrix[row-1][col-1]);
}
printf("\n");
}
printf("Your matrix is :\n\n\t\t");
for(row=0;row<row_t;row++)
{
for(col=0;col<col_t;col++)
{
printf("%d\t",matrix[row][col]);
}
printf("\n\t\t");
}
printf("\nDiagonal is: \n\t\t");
for(row=0;row<row_t;row++)
{
for(col=0;col<col_t;col++)
{
if(row==col)
{
printf("%d\t",matrix[row][col]);
}
}
}
printf("\nAvove is: \n\t\t");
for(row=0;row<row_t;row++)
{
for(col=0;col<col_t;col++)
{
if(row<col)
{
printf("%d\t",matrix[row][col]);
sumAvb+=matrix[row][col];
}
}
}
printf("\nBelow is : \n\t\t");
for(row=0;row<row_t;row++)
{
for(col=0;col<col_t;col++)
{
if(row>col)
{
printf("%d\t",matrix[row][col]);
sumBlw+=matrix[row][col];
}
}
}
printf("\nSum of avove is = %d\nSum of below is = %d \n\n", sumAvb, sumBlw);
getch();
}