Would anyone help me to find out which client is closest to the average found? When compiling 1.QNAN0 which is when I make a malformed math operation, I just do not see which one it is: / header file to compile
#include <stdio.h>
#include "exercicios.h"
#include <strings.h>
struct cliente reg [50];
float media(int , int);
void cria_cli(int i, int f){
for (;i<f;i++)
{
reg[i].codigo=i+1;
reg[i].potencia=potencia[i];
strcpy(reg[i].nome,clientes[i]);
reg[i].preco=preco[i];
reg[i].status='*';
}
}
void lista_cli(int i, int f){
for (;i<f;i++)
{
printf("%d - %-20s \n", reg[i].codigo, reg[i].nome);
}
printf("media - %f ",media(0,50));
}
float media(int i, int f){
float dif=1.0, p;
float media;
float m=0;
for (;i<f;i++)
{
m+= (reg [i].potencia * reg[i].preco);
}
media = m/f;
for (;i<f;i++)//ord
if(media-(reg[i].potencia * reg[i].preco)<dif){
dif = media - (reg[i].potencia * reg[i].preco);
p = reg[i].potencia * reg[i].preco;
}
}
int main(){
cria_cli(0,50);
lista_cli(0,50);
}