0
I’m a beginner in C programming, and in college we had to develop a program to make the average of 4 notes, and after typed, make the display, the program works without syntax error, but there’s something wrong in the final result, which displays the average result, for me, any value I put it returns the result as 0. Can anyone tell me where the error is? This is the program:
int main()
{
float media,nota1,nota2,nota3,nota4;
printf("\nEntre com as 4 notas: \n");
scanf("%f" ,¬a1);
scanf("%f" ,¬a2);
scanf("%f" ,¬a3);
scanf("%f" ,¬a4);
media=(nota1+nota2+nota3+nota4)/4;
printf("\nA media e': %f", &media);
}
Here:
printf("\nA media e': %f", &media);
doesn’t have this&
before the media. Use:printf("\nA media e': %f", media);
. Note that it is in the scanf function that we must provide the variable address.– anonimo
Now that you’ve shown that I even remembered you can’t have the
&
on the printf– Breno Leonetti