Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- typedef struct Student
- {
- char name[100];
- char birth_date[12];
- float scores[10];
- } Student;
- int student_number;
- printf("Number of students: ");
- scanf("%d", &student_number);
- Student *students = malloc(sizeof(Student) * student_number);
- int i;
- for(i = 0; i < student_number; i++) {
- printf("Student number %d", i);
- printf("Name, Birth date %d", i);
- scanf("%s %s", &students[i].name, &students[i].birth_date);
- printf("Number of exams for the student %s", students[i].name);
- int exam_number;
- scanf("%d", &exam_number);
- int j;
- for(j = 0; j < exam_number; j++) {
- printf("Exam number %d", j);
- scanf("%f", &students[i].scores[j]);
- }
- }
- printf("Printing student average: \n");
- for(i = 0; i < student_number; i++) {
- printf("Student number %d - Name: %s - date of bird: %s ", i, students[i].name, students[i].birth_date);
- float sum = 0;
- int j;
- for(j = 0; j < sizeof(students[i].scores) / sizeof(int); j++) {
- sum += students[i].scores[j];
- }
- printf("Student average: %f", sum);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement