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);
}

For your reference ~

CodePudding user response:

The
reference 1/f, confident boy reply:
 # 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);
}

For reference ~

The char name [] in the scanf function should be no & amp; the

CodePudding user response:

An array of char types defined reading style do not need to write the address-of operator & amp; , its name is address

CodePudding user response:

The
reference 3 floor weixin_45917216 response:
array of char types defined reading style do not need to write the address-of operator & amp; , its name is address

That's what I mean, when Posting conveniently give written

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html