#why is in this loop it's not entering the if statements at lines 75, 86?

30 messages · Page 1 of 1 (latest)

shadow ravine
compact harnessBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

still dust
#

discord doesn't have line numbering

shadow ravine
still dust
#

!code

compact harnessBOT
#
How to Format Code on Discord
Markup

```c
int main() {}
```

Result
int main() {}
still dust
#

you can probably cut most of that out too, you only need to post the relevant parts

shadow ravine
#
            //finding the max final grade 
            maxFgrade = (((course->students + course->studentNum)->Fgrade) > (maxFgrade)) ? (course->students + course->studentNum)->Fgrade : maxFgrade;
            
            
            if (((course->students + course->studentNum)->Fgrade) > (maxFgrade))
            {
                (*maxLoc)++;
            }

            //test if right, delete later
            printf("the max grade for the first %d students is %lf\n", course->studentNum + 1, maxFgrade);
            
            //finding the min final grade
            minFgrade = (((course->students + course->studentNum)->Fgrade) < (minFgrade)) ? (course->students + course->studentNum)->Fgrade : minFgrade;
            

            if (((course->students + course->studentNum)->Fgrade) < (minFgrade))
            {
                (*minLoc)++;
            }

            printf("minloc is %d and maxloc is %d inside the loop\n", *minLoc, *maxLoc);

            //test if right, delete later
            printf("the min grade for the first %d students is %lf\n", course->studentNum + 1, minFgrade);


            (course->studentNum)++;
        }
        else {
            printf("there are %d students in the course.\n", (course->studentNum));
            break;
        }
    } while (choice == 1);
    
    printf("minloc is %d and maxloc is %d outside the loop\n", *minLoc, *maxLoc);
shadow ravine
#

ive given this code these inputs, and you can see it always outputs that *minLoc or *maxLoc are 0 when they should be bigger

#
Please enter 4 numbers (>0 and <1) for average weights (the fifth will fill automatically):
0.2
0.2
0.2
0.1
the 1-th weight is 0.200000
the 2-th weight is 0.200000
the 3-th weight is 0.200000
the 4-th weight is 0.100000
the 5-th weight is 0.300000
Would you like to add a new student? (1) yes (any other number) no?
1
Hello, please enter the student's name:
aaaaa
the student name entered is aaaaa
Please insert student id:
65165
the student ID inputed is 65165
Please insert student grades:
80
70
90
80
90
the student 1-th grade is 80
the student 2-th grade is 70
the student 3-th grade is 90
the student 4-th grade is 80
the student 5-th grade is 90
the final grade of aaaaa is 83.000000
Would you like to add a new student? (1) yes (any other number) no?
1
Hello, please enter the student's name:
ddddddddd
the student name entered is ddddddddd
Please insert student id:
516515
the student ID inputed is 516515
Please insert student grades:
90
90
100
90
90
the student 1-th grade is 90
the student 2-th grade is 90
the student 3-th grade is 100
the student 4-th grade is 90
the student 5-th grade is 90
the final grade of ddddddddd is 92.000000
the max grade for the first 2 students is 92.000000
minloc is 0 and maxloc is 0 inside the loop
the min grade for the first 2 students is 83.000000
still dust
shadow ravine
#

it was my attemt at making a flag of the address of the maxFgrade and minFgrade

still dust
#

well presumably it's because the Fgrade isn't above maxFgrade and isn't below minFgrade

shadow ravine
still dust
#

that's all meaningless to me

#

the things handling and producing that input and output aren't shown in your code

#

(that's not an invitation to post all of it)

shadow ravine
still dust
#

the last 4 lines look perfectly fine to me

#

the max grade of the first 2 students is indeed 92, and the min grade is indeed 83

shadow ravine
#

so it should have incrimented one of *minloc or *maxloc

#

but both are zero still

still dust
#

have you stepped through with a debugger and inspected values?

shadow ravine
still dust
#

<= makes more sense to me

bronze owl