Home > Back-end > Recorded in structure of a class student id, name, and the educational, calculate a score and output
Recorded in structure of a class student id, name, and the educational, calculate a score and output
Time:06-07
#include # define N 30 Struct student { int num; Char name [3]. Float g1;/* educational g1g2g3 */ Float g2. Float g3; Float total; }; Void main () { Struct student st [N]. int i; Printf (" please, in turn, enter the student id, name, educational "); for(i=0; i{ The scanf (" % d % s % f % f % f ", & amp; St [I]. Num, & amp; St [I]. Name, & amp; St [I] g1, & amp; St [I]. G2, & amp; St [I]. G3); St [I]. Total=st [I] g1 + st [I] [I] g2 + st g3;/* calculating educational */ } for(i=0; iNum: printf (" % d, name: % s, g1: %, 2 f, g2: %, 2 f, the g3: %, 2 f, total: %, 2 f \ n ", st [I] num, st [I]. Name, st [I] g1, st [I] g2, st [I] g3, st [I] total); }
CodePudding user response:
# include
# define N 30
Struct student { int num; //char name [3]. Char name [16]. Float g1;/* educational g1g2g3 */ Float g2. Float g3; Float total; };
//void main () Int main () { Struct student st [N]. int i; Printf (" please, in turn, enter the student id, name, educational "); for(i=0; i{ //the scanf (" % d % s % f % f % f ", & amp; St [I]. Num, & amp; St [I]. Name, & amp; St [I] g1, & amp; St [I]. G2, & amp; St [I]. G3); The scanf (" % d % s % f % f % f ", & amp; St [I]. Num, st [I]. Name, & amp; St [I] g1, & amp; St [I]. G2, & amp; St [I]. G3); St [I]. Total=st [I] g1 + st [I] [I] g2 + st g3;/* calculating educational */ } for(i=0; iNum: printf (" % d, name: % s, g1: %, 2 f, g2: %, 2 f, the g3: %, 2 f, total: %, 2 f \ n ", st [I] num, st [I]. Name, st [I] g1, st [I] g2, st [I] g3, st [I] total); }