I’m not getting these steps ! I wanted help

Asked

Viewed 34 times

-1

(b) Find the student with the highest score of 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;
}
  • Previous question (not duplicated): https://answall.com/q/307649/132

1 answer

0

First, although it is not strictly necessary, things will get easier if you add a field float media in his struct. To fill this field, use a variable soma inside the for do i and within the loop of j, you keep adding up the notes in this vaivable. After the loop of the j, you calculate the average and then fill this field in struct.

Then you’ll need three variables int different, to keep the number of students (from 0 to 4) who are the solution of each of these. For example, int aluno_com_maior_nota_da_primeira_prova, int aluno_com_maior_media and int aluno_com_menor_media. Boot all with 0.

At the end of the i, you put a if to check if the student’s first test score i is better than the student’s first test score in the position aluno_com_maior_nota_da_primeira_prova. You do something similar to the other two variables.

Finally, after the bow of i, you put some printfs to show who are the students who meet these three criteria.

In addition, the variables media, Mmedia, mmedia can be ruled out. The problem with them is that you don’t want to know what the average student is or something like that and you do want to know which student which has the average according to the statement. Since the three problems deal with knowing which students are and which students can be numbered from 0 to 4, then you will be dealing with three variables int and not float.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.