void main()
{
int A[5][5],i,j,m,n,sum = 0;
clrscr();
printf(“nnt ENTER A ORDER OF THE MATRIX M,N…: “);
scanf(“%d,%d”,&m,&n);
printf(“nnt ENTER THE ELEMENTS OF THE MATRIX..:nn”);
if(m == n)
{
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
gotoxy(20+j*4,12+i*2);
scanf(“%d”,&A[i][j]);
}
printf(“n”);
}
for(i=1;i<=m;i++)
sum = sum + A[i][n+1-i];
printf(“nt THE SUM OF SECONDARY DIAGONAL OF A MATRIX IS…: %d”, sum);
}
else
{
printf(“nt THE ORDER OF THE MATRIX IS NOT CORRECT”);
printf(“nnt HELP : ‘M’ SHOULD BE EQUAL TO ‘N’”);
}
getch();
}
Not Satisfied ? Just search & get the result
Related posts:
- C program to find accept a matrix of order M x N and find the sum of the main diagonal and off diagonal elements
- C program to accept a matrix of order MxN and find the trace and normal of a matrix HINT:Trace is defined as the sum of main diagonal elements and Normal is defined as square root of the sum of all the elements
- C program to accept a matrix of order M x N and store its elements and interchange the main diagonal elements of the matrix with that of the secondary diagonal elements
- C program to accept a matrix of order M x N and find the sum of each row and each column of a matrix
- C program to read a matrix A (MxN) and to find the following using functions a) Sum of the elements of each row b) Sum of the elements of each column c) Find the sum of all the elements of the matrix Output the computed results with suitable headings
