You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
860 B
43 lines
860 B
1 year ago
|
#include <stdio.h>
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|