0
I need to sum each column of a 3X3 matrix.
What I got so far:
#include <stdio.h>
int main()
{
int matriz[3][3] =
{
{ 5, -8, 10 },
{ 1, 2, 15 },
{ 25, 10, 7}
};
int array[3] = {0};
for(int linha = 0; linha < 3; linha++){
for(int coluna = 0; coluna < 3; coluna++){
printf("%d ", matriz[linha][coluna]);
}
printf("\n");
}
int soma;
for(int lin = 0; lin < 3; lin++){
soma = 0;
for(int col = 0; col < 3; col++){
soma = soma + matriz[lin][col];
}
array[col] = soma;
}
printf("\nA soma das colunas da matriz é:\n");
for(int r = 0; r < 3; r++){
printf("%d ", array[r]);
}
return 0;
}
And the question is what? Say one that is punctual and specific.
– Piovezan
You said what you want to do, but you didn’t describe the problem you’re having.
– isaque