I would like to know why my code is not returning the correct values, because when I type the value it does not calculate correctly, like entering two notes, both being and 5.0 , the output should be 5.0 and this is not happening.
Use the amortized mean harmonic formula to make the program.
The following is 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;
}