/* Illustrative example of the constructs struct and typedef. The program must: - Defines a new data type with name ''stud_t'' based on a structure useful to store information about a student. - The structure (identified in a C program with the keyword ''struct'') must contain: - a field ''number'' to store the //identification number// of the student - a field ''name'' to store the //name// of the student (the student name has a maximum length of 20 characters) - a field ''average'' to store the average value of the scores of a student - a vector of ''scores'' to store the scores of the exams attended by the student - The program, after declaring a vector (whose elements are of type ''stud_t'') useful to store the data related to ''N_STUD'' students. - It must fill all the fields related to the student with index ''0'' in the vector of type ''stud_t''. - And finally, it must print all the fields related to the student with index ''0'' previously inserted. */ #include #include #define DIM_NAME 20 #define N_SCORES 3 #define N_STUD 10 /* Definition of the new type stud_t */ typedef struct { int number; char name[DIM_NAME+1]; float average; int scores[N_SCORES]; } stud_t; int main(){ /* Declaration of the vector of stud_t */ stud_t student[N_STUD]; int i; /* Filling of the fields of the structure referred to the student index with index 0 of the vector */ strcpy(student[0].name, "Jules"); student[0].number = 13123; student[0].average = 23.0; student[0].scores[0] = 18; student[0].scores[1] = 27; student[0].scores[2] = 24; /* Printing of the values previously written */ printf("%d %s %f\n", student[0].number, student[0].name, student[0].average); for(i=0; i