/*************************************** ************************
C Language
AUTHOR: liuyongshui
**************************************** ***********************/
/*
Question 16: each student's student ID, name, C ++, high number, and English score define an array of student scores, the data members include student ID (char num [12]), name (name), grade, total score, and average )).
(1) enter the information of five students on the keyboard;
(2) calculate the total score and average score of each student, and store them in the struct array (you can calculate the total score by the way during the reading process );
(3) Calculate the student ID, name, total score, and average score of each student.
*/
# Include <stdio. h>
Struct stu
{
Char num [12];
Char name [15];
Float cpp;
Float english;
Float math;
Float score;
Float average;
};
Void calculate (struct stu schlastic []); // calculate the total score and average score of Students
Int main ()
{
Int I;
Struct stu student [5];
Printf ("enter the information of five students... \ n ");
Printf ("student ID \ t name \ t English Score \ t High \ tC ++ Score \ n ");
For (I = 0; I <5; I ++)
{
Scanf ("% s % f", student [I]. num,
Student [I]. name, & student [I]. english,
& Student [I]. math, & student [I]. cpp );
}
Calculate (student );
Return 0;
}
// Function Definition
Void calculate (struct stu scholatic [])
{
Int I;
For (I = 0; I <5; I ++)
{
Scholatic [I]. score = scholatic [I]. average = 0.0;
Scholatic [I]. score = scholatic [I]. math +
Scholatic [I]. english +
Scholatic [I]. cpp;
Scholatic [I]. average = scholatic [I]. score/3;
}
Printf ("output the total score and average score of each student: \ n ");
For (I = 0; I <5; I ++)
{
Printf ("% d student: Student ID: % s name: % s total score: % f average score: % f \ n", I + 1, scholatic [I]. num,
Scholatic [I]. name,
Scholatic [I]. score,
Scholatic [I]. average );
}
}