answersLogoWhite

0

/* 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

14y ago

What else can I help you with?

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?

Consider a rhombus ABCD, whose diagonals intersect at O. We know that diagonals of a rhombus bisect each other at 90°, so triangles AOB, AOD, BOC and COD are right angled triangles. In ΔAOB, AO2 + OB2 = AB2 (Using Pythagoras theorem) ⇒ AC2 + BD2 = 4AB2 Similarly, AC2 + BD2 = 4BC2 AC2 + BD2 = 4CD2 AC2 + BD2 = 4AD2 Adding all these equations, we get 4(AB2 + BC2 + CD2 + AD2) = 4(AC2 + BD2) ⇒ AB2 + BC2 + CD2 + AD2 = AC2 + BD2


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.


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

truzi i Ghal


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 do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


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.


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 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!


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 ]