Struct! You are giving error on line 47 at the time it compiles, Follow the program in c

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

int main(){
    struct aluno;
    int i;
    int j;

    printf("Determine o Nome do Aluno %d: ", i+1);
    printf("Determine a Matricula do Aluno &d: ", i+1);
    for(i=0;i<5;i++){
        fgets(aluno[i].nome,MAX,stdin);
        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 / 02:18

1 answer

3

When you do this:

    struct aluno;

You are trying to declare a variable incorrectly. Remove this line because aluno has already been declared before as a 5-position array with struct type.

Look at this line:

    printf("Determine a Matricula do Aluno &d: ", i+1);

Instead of &d , you should use %d .

These first two printf s should be within for , not before it.

In your second for , you use three notes, but you have not declared all three in struct .

I think what you wanted was this:

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

int main() {
    int i;
    int j;

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

        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;
}
    
17.06.2018 / 02:35