Asked 5 months ago, Updated 5 months ago, 10 views

I have the following problems at the university, but I am having a hard time because I don't know how to build the program.

Declare a structure consisting of three points: name, math, and English. (Data such as "Nomo", 78, 64 were given) Declare a structure with ave added to store the mean points of two subjects and create an objave function to store in ave of each object.(←This is done) In addition to this, create a maxave function that stores the object max for math and English scores of students with the largest average score, and display the object max's math, eng, and ave as the main function.

I wrote it halfway, but I would appreciate it if you could tell me what is missing and what is unnecessary.Thank you for your cooperation.


// Declaration of structure
US>structure score {
    char name [20];
    int path;
    double ave;
//objave function
void objave(struct score*val) {
    // (average) = (total English and math)/2
    val->ave=(val->eng + val->math)/2;
// maxave function
void maxave(struct score*val) {
    val->ave=max(val->ave, 0);

int main() {
    // Describe the data corresponding to the structural members in order
    structure score nomo= {"Nomo", 78,64};
    structure score matsui={"Matsui", 65,30};
    structure score suzuki={"Suzuki", 82,90};
    structure score max={};
    Calling //objave Function
    // objave(&nomo);
    // objave(&matsui);
    // objave(&suzuki);

    printf("math:%deng:%dave:%f\n", max.math, max.eng, max.ave);


2022-09-30 14:13

1 Answers

It's a challenge, so just a hint.
I think it is necessary to prepare a Score array and pack nomo, matsui, and suzuki and give it to maxave.

2022-09-30 14:13

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.