Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Programming, find the sum of the elements of the main diagonal of a 4*4 plastic matrix.
Programming, find the sum of the elements of the main diagonal of a 4*4 plastic matrix.
# include & ltstdio.h & gt

Master ()

{

int i,j,s[4][4],sum = 0;

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

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

{

Prinf ("\ nPlease enter data:");

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

}

for(I = 0; I<4, i++)

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

if(I = = j)sum+= s[I][j];

Printf ("\ nthe total is %d", sum);

}

No, that's basically it.