answersLogoWhite

0


Best Answer
/* Ramana Reddy -IIIT */

#include
main()
{
int a[10][10],i,j,m,n,sum=0;
printf("Size of Matrix M*N:\n ");
scanf("%d%d",&m,&n);
if(m==n)
{
printf("\nEnter %d elements: \n",m*n);

for(i=0;i for(j=0;j scanf("%d",&a[i][j]);
for(i=0;i {

for(j=0;j {

printf("%d",a[i][j]);

if(i==j)

sum=sum+a[i][j];

}
}
}
printf("\nSum of diagonal elements = %d\n",sum);
}
User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sum of all diagonals of a square matrix by using c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you find the sum of diagonals in a matrix?

Add the numbers.


When you know the sum of lengths of diagonal of a square how to find each diagonal?

To find the length of each diagonal of a square, divide the sum of the diagonal lengths by 2. Since a square has two diagonals of equal length, this division will give you the length of each diagonal.


What is a matrix and a scalar?

A matrix and a scalar is a matrix. S + M1 = M2. A scalar is a real number whose square is positive. A matrix is an array of numbers, some of which are scalars and others are vectors, square of the number is negative. A matrix can be a quaternion, the sum of a scalars and three vectors.


Is the sum of squares of the sides of a rhombus is equal to sum of square of the diagonals?

No, the sum of squares of the sides of a rhombus is not equal to the sum of squares of the diagonals. The sum of the squares of the sides of a rhombus is equal to four times the square of one side, while the sum of the squares of the diagonals is equal to two times the sum of the squares of the sides.


Determine whether or not the given square is a magic square?

A 3x3 magic square means that each row, each column, and both diagonals all have the same sum.


Write a C program using dynamic memory allocation to find the sum of elements of a matrix?

Did you know that memory allocation is not needed to display the matrix? However, the C program is to find the sum of all the elements.


How to write a code for finding sum of left diagonals elements in an array using c plus plus?

truzi i Ghal


How do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


Write a program using iostreams to take as input two multi-dimensional arrays and print their sum as output Matrix Addition in Matrix format?

http://www.assignmentsclub.com/


What is the sum of lengths of the two diagonals in a rectangle 5 by 12?

The sum of the lengths of the two diagonals in a rectangle can be found using the Pythagorean Theorem. For a rectangle with sides measuring 5 and 12 units, the length of the diagonal can be calculated as √(5^2 + 12^2). Therefore, the sum of the lengths of the two diagonals in this rectangle would be 5√(5^2 + 12^2) units.


In a magic square of 9 spaces the sums of the columns rows and diagonals are all the same Using the digits 2-10 only once fill in the blanks to make this figure a magic square with a sum of 18?

[ 9 ] [ 2 ] [ 7 ][ 4 ] [ 6 ] [ 8 ][ 5 ] [10 ] [ 3 ]


What is the sum of a pentacontakaipentagon?

A shape does not have a sum. The angles of a shape have a sum, the lengths of its sides have a sum, the number of its diagonals are a sum, but the shape itself certainly does not have any sum!