#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LICZBA_OCEN 5
float oceny[LICZBA_OCEN] = { 3, 3.5, 4.5, 5, 5 };
typedef struct {
char imie_nazwisko[50];
float oceny[LICZBA_OCEN];
} Student;
void wyswietl (Student * student) {
printf ("%s\n", (*student).imie_nazwisko);
int i;
for (i = 0; i < LICZBA_OCEN; i++) {
printf ("%.1f\n", (*student).oceny[i]);
}
}
float srednia (Student * student) {
float suma = 0;
int i;
for (i = 0; i < LICZBA_OCEN; ++i) {
suma = suma + (*student).oceny[i];
}
return suma/LICZBA_OCEN;
}
int main () {
Student s;
strcpy (s.imie_nazwisko, "Novikov Oleksandr");
s.oceny[0] = 4.5;
s.oceny[1] = 5;
s.oceny[2] = 3.5;
s.oceny[3] = 3;
s.oceny[4] = 5;
wyswietl (&s);
printf ("Srednia: %.2f", srednia (&s));
}