Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Find the sum of diagonal elements of a 3*3 shaping matrix. Programming in c language.
Find the sum of diagonal elements of a 3*3 shaping matrix. Programming in c language.
Collect it first, then deal with it. # include & ltstdio.h & gt

# include & ltstdlib.h & gt

int main()

{

int i,j,m=0,a[3][3];

Printf ("Please enter 9 integers \ n");

for(I = 0; I<3; i++)

for(j = 0; j & lt3; j++)

scanf("%d ",& ampa[I][j]);

for(I = 0; I<3; i++)

for(j = 0; j & lt3; j++)

if(I = = j)m+= a[I][j];

Printf ("The sum of diagonal elements is: %d\n", m);

System ("suspended");

Returns 0;

}