C Program to Find the Diagonal Sum of Matrix
This is the C Program to find the diagonal sum of a matrix
#include<stdio.h>
void main()
{
int a[10][10],i,j,fwsum=0,rwsum=0,n;
printf("Enter the no. of rows and columns for Matrix :");
scanf("%d",&n);
printf("nnNow enter the Matrix A[%d][%d] :-nn",n,n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("Row[%d] Column[%d] :",i,j);
scanf("%d",&a[i][j]);
}
}
for(j=0;j<n;j++)
{
fwsum+=a[j][j];
}
printf("nnForward Diagonal Sum = %d",fwsum);
}
Recent Comments