0
I wonder why my code is not returning the correct values, because when I type the value it does not calculate correctly, how to enter with two notes, both valid 5.0 and 5.0, the exit should be 5.0 and this is not happening.
Use the amortized harmonic mean formula to make the program.
Follow the code below:
#include <stdio.h>
int main (void)
{
int N, i;
float mediaharmonica, res;
scanf("%d", &N);
float vetor[N];
for (i = 0 ; i < N ; i++)
{
scanf("%f", &vetor[i]);
res = 1/(vetor[i] + 1);
mediaharmonica = N - 1 /(float)res;
}
printf("%.2f", mediaharmonica);
return 0;
}