Error in the average calculation of a student record

Asked

Viewed 62 times

1

printf("Nota 1: ");
scanf("%.1f", &alu[n].not1);

printf("Nota 2: ");
scanf("%.1f", &alu[n].not2);
alu[n].media = (alu[n].not1+alu[n].not2)/2; // o erro acontece NESSA LINHA

invalid operands to Binary + (have 'float *' and 'float *')

I always find error in the highlighted line with comment, someone can tell me why ?

  • How the variable structure is defined alu?

  • typedef struct { int matricula[10]; char name[80]; int datanasc[8]; float not1[3]; float not2[3]; float media[3]; Date aniv; } Students;

  • Why Nota1, nota2 and mean are vectors?

  • I honestly don’t know either , I’m doing this work together with a classmate and he sent me his share like this :/

1 answer

2


Change structure for this that must solve:

typedef struct {
    int matricula;
    char nome[80];
    int datanasc;
    float not1;
    float not2;
    float media;
    Data aniv;
} Alunos;

I put in the Github for future reference.

Only the string needs to be a array of characters. The way it was it had 3 notes each, which doesn’t look like what you want. I understood that I wanted it to have 3 digits. A floating point number has its own shape and you don’t control the size of it. What you can do next is limit the textual representation of the number to display only what you want.

I think there may still be other problems there, like the date of birth being a whole, but you’re the one who knows what you’re doing. I hope it exists and can handle the guy Data. Besides it’s weird to have a birthday and a birthday.

  • Actually the error was solved , only now the media variable is not receiving calculation but thank you :)

  • There’s another problem, I imagine there are several in the same code.

  • Yes, yes :/, it is a double job and he sent me his share so I will have to review everything but thank you, it helped me a lot :)

Browser other questions tagged

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