Write a function to obtain the trace of a given square matrix of order m x
m. (Trace of a matrix is defined as the sum of leading diagonal elements of
the matrix. )
#include
#include
void main()
{
int a[10][10],m,n,i,j,sum=0;
clrscr();
printf("\nEnter number of rows");
scanf("%d",&m);
printf("\nEnter number of columns");
scanf("%d",&n);
if(m==n)
{
printf("Enter values for matrix");
for(i=0;i