I have a problem with a mean calculation.
I have a struct with 3 fields. The ones I'm wanting to average are quantity of products and unit value. I need to average between all products and their prices. However, when I have unit values with 0.50 for example, it does not add to the calculation and only averages values that start with a minimum of 1.00. The quantity is int and the value is float.
The sum and mean is as follows:
int x;
double soma=0,media;
for(x=0;x<n;x++)
{
soma+=((prod[x].PRECO)*(prod[x].QTDE));
}
media=soma/n;
printf("\n\n\nA media de valor entre todos os produtos estocados eh: %.2lf", media);