3
In the letter i was to give 9,2 but the result that shows is 9,50.
How to find out which class has the most homogeneity in relation to grades?
float turma1[4][5] ={
{8.2,9.2,8.7,6.0,7.0},
{3.0,3.4,9.2,9.8,1.9},
{4.0,5.2,8.2,7.2,8.7},
{10,4.8,8.2,6.7,8.2}
};
float turma2[4][5] ={
{6.5,6.5,7.2,7.2,7.8},
{9.0,9.2,9.1,8.0,8.2},
{3.5,7.9,6.9,9.2,9.2},
{8.9,9.2,9.7,10,8.5}
};
int i,j;
//i) Qual nota foi a mais frequente na turma 2?
float notaMaisFrequente;
for(i=0;i<4;i++){
for(j=0; j<5;j++){
if(turma2[i][j] == turma2[i][j]){
turma2[i][j] = turma2[i][j]+1;
notaMaisFrequente = turma2[i][j];
}
}
}
printf("Nota mais frequente na Turma 2: %.2f",notaMaisFrequente);
I compiled here and appeared: Student 0 of Class 2 had the highest average. Most frequent grade in Class 2: 9.50
– Luiz Augusto
I’m analyzing your code, there’s a logic error on the condition: if(class 2[i][j] == class 2[i][j]) I’m just thinking of a way for a variable to receive which vector repeats more
– Luiz Augusto
My friend, I’ll have to leave soon, so I’ll try to answer your question until tomorrow, in case I don’t make it, I’ll offer a reward for someone from the community to help!
– Luiz Augusto
Okay, I’m still grateful you tried to help me
– bbyink
The error, as has already been said, is in the
if(turma2[i][j] == turma2[i][j])
, what you have to do is save all the numbers that came out and, in case the number has already come out once, you have to add 1 in the number of times it came out...– Felipe Avelar