diff --git a/step2.c b/step2.c new file mode 100644 index 0000000..b072941 --- /dev/null +++ b/step2.c @@ -0,0 +1,42 @@ +#include + +typedef struct { + char id[6]; + double math; + double physics; + double english; + double total; +} Student; + +void inputStudentInfo(Student *student) { + scanf("%s", student->id); + scanf("%lf", &student->math); + scanf("%lf", &student->physics); + scanf("%lf", &student->english); + student->total = student->math + student->physics + student->english; +} + +void displayStudentInfo(Student student) { + printf("%s %.1lf %.1lf %.1lf %.1lf\n", + student.id, + student.math, student.physics, student.english, student.total); +} + +int main() { + Student students[3]; + + int i=0; + while(i<3) + { + inputStudentInfo(&students[i]); + i++; + } + + printf("\n"); + for (int i = 0; i < 3; i++) { + displayStudentInfo(students[i]); + } + + return 0; +} +