5
Hello! I need to resolve the following question, but I’m not getting it.
Write an algorithm that calculates the average arithmetic of the students' 3 grades (number undetermined of pupils) of a class. The algorithm should read, in addition to the notes, the code of the student and should be terminated when the code is zero
I wrote the code below, I do not know what is wrong, because when "code = 0" it does not close. Someone can help me?
main()
{
int codigo, n1, n2, n3, i;
float media;
while(codigo != 0){
for(i= 0; i >= 0; i++){
printf("Digite o código do aluno:\n");
scanf("%d", &codigo);
printf("Digite as 3 notas do aluno:\n");
scanf("%d %d %d", &n1, &n2, &n3);
media = ((n1+n2+n3)/3);
printf("Media = %.2f\n", media);
}
}
return 0;
}
You don’t need the block
for
, note that you declarei
and the variable is not used inside the block.– Wilson Freitas