The avg would print as the first number it obtained. Someone with no programming skills like myself would think if it were grabbing the first number it would divide the number by 5 because that's in the print statement.
The avg would print as the first number it obtained. Someone with no programming skills like myself would think if it were grabbing the first number it would divide the number by 5 because that's in the print statement.
I am a dumb arse tabstop think you.
I'm sure it is dividing by 5. But you are adding the first element to itself 5 times (your for loop).
Logically, (5 * i) / 5 = i
Change your 5 to a 12, or whatever, you'll see.
Syntax lesson:
t->grade is the same as (*t).grade.
t->grade[i] is the same as *(t->grade + i).
*t->grade is the same as t->grade[0].
Remember: [] actually dereferences the pointer, so it's
t->grade[i]
and not
*t->grade[i].
Again, see above, and you'll see that your syntax keeps grabbing the first element all the time.
You must do t->grade[i].