#include <stdio.h>
int main()
{
int a[3][3],i,j,n=3,sum=0;
printf("\nEnter matrix elements:\n ");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d", &a[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d", a[i][j]);
}
printf("\n\n");
}
for(i=0;i<n;i++)
{
sum = sum+a[i][i];
}
printf("\nDiagonal element sum: %d",sum);
return 0;
}
Comments
Post a Comment