I can not do these steps! I wanted help

-1

(b) Find the student with the highest grade in the first test.

(c) Find the student with the highest overall average.

(d) Find the student with the lowest overall average.

#define MAX 50
struct {
    int ra;
    char nome[MAX];
    float prova[3];
} aluno[5];

int main() {
    int i;
    int j;
    float media, Mmedia, mmedia;

    for (i = 0; i < 5; i++) {
        printf("Determine o Nome do Aluno %d: ", i + 1);
        scanf("%s", &aluno[i].nome);

        printf("Determine a Matricula do Aluno %d: ", i + 1);
        scanf("%i", &aluno[i].ra);

        for (j = 0; j < 3; j++) {
            printf("Determine a nota da %d Prova: ", j + 1);
            scanf("%f", &aluno[i].prova[j]);
        }
    }
    return 0;
}
    
asked by anonymous 17.06.2018 / 04:41

1 answer

0

First, although it's not strictly necessary, things will get easier if you add a float media field to your struct . To populate this field, use a soma variable within the i and within the j loop, you add the notes to that variable. After the j loop, you calculate the mean and then fill that field in struct .

Next, you will need three different%% variables to store the number of students (from 0 to 4) that are the solution to each of those. For example, int , int aluno_com_maior_nota_da_primeira_prova and int aluno_com_maior_media . Initialize all with 0.

At the end of the int aluno_com_menor_media loop, you set a i to check that the first test score for the if student is better than the first test score for the student at i position. You do something similar to the other two variables.

Finally, after the aluno_com_maior_nota_da_primeira_prova loop, you put some i s to show who the students meet these three criteria.

In addition, the variables printf , media , Mmedia can be discarded. The problem with them is that you do not want to know what the student's average or similar is, but to know which student has the average according to the statement. Since the three problems are to know which students and students can be numbered from 0 to 4, then you will be dealing with three variables mmedia and not int .

    
17.06.2018 / 07:36