Files
learn.c/matrixes/ex3.c
Gustavo "Guz" L de Mello e05749d7fb feat(matrixes): matrixes exercises
I skiped the vector ones since they were too simple
2026-03-30 17:02:46 -03:00

33 lines
738 B
C

#include <stdio.h>
#include <stdlib.h>
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
int main(void) {
double matrix[5][4];
for (int i = 0; i < NELEMS(matrix); i++) {
for (int j = 0; j < NELEMS(matrix[i]); j++) {
printf("Digite a nota n° %d do aluno %d: ", j, i + 1);
scanf("%lf", &matrix[i][j]);
}
}
for (int i = 0; i < NELEMS(matrix); i++) {
double sum = 0;
for (int j = 0; j < NELEMS(matrix[i]); j++) {
sum += matrix[i][j];
}
double avarage = sum / ((double)NELEMS(matrix[i]));
printf("Média: %.2f", avarage);
if (avarage >= 6) {
printf(" Aluno %d APROVADO\n", i + 1);
} else {
printf(" Aluno %d REPROVADO\n", i + 1);
}
}
return EXIT_SUCCESS;
}