2
How do I remove the 0.00000 printings in the response of that program after the functions idealBrutus
and idealOlivia
are called in the function main
?
I realized that if, for example, I change line 59 from the original to:
printf ("%s", idealBrutus (imcBrutus,pBrutus, hBrutus, strBrutus));
I will receive a (null
) after the function is idealBrutus
be used.
#include <stdio.h>
#include <cmath>
float imc (float peso, float altura)
{
return ( peso / pow(altura, 2));
}
float idealBrutus (float imc, float peso_inicial,float altura, char nome[100])
{
float dif_para_o_peso_ideal;
float peso_ideal;
peso_ideal = 25 * pow(altura,2);
dif_para_o_peso_ideal = abs(peso_ideal - peso_inicial);
printf ("Para ficar com o Imc ideal %s ", nome);
printf ("deve perder %f kg \n", dif_para_o_peso_ideal);
}
float idealOlivia (float imc, float peso_inicial,float altura, char nome[100])
{
float dif_para_o_peso_ideal;
float peso_ideal;
peso_ideal = 18.5 * pow(altura,2);
dif_para_o_peso_ideal = abs(peso_ideal - peso_inicial);
printf ("Para ficar com o Imc ideal %s ", nome);
printf ("deve ganhar %f kg \n", dif_para_o_peso_ideal);
}
int main ()
{
char strBrutus[100] = "Brutus";
float hBrutus;
float pBrutus;
float imcBrutus;
char strOlivia[100] = "Olivia";
float hOlivia;
float pOlivia;
float imcOlivia;
pBrutus = 122;
hBrutus = 1.84;
pOlivia = 45;
hOlivia = 1.76;
imcBrutus = imc (pBrutus, hBrutus);
imcOlivia = imc (pOlivia, hOlivia);
printf ("O imc de Brutus e : %f \n", imcBrutus);
printf ("%f", idealBrutus (imcBrutus,pBrutus, hBrutus, strBrutus));
printf ("O imc de Olivia e : %f \n", imcOlivia);
printf ("%f", idealOlivia (imcOlivia,pOlivia, hOlivia, strOlivia));
}
Of all the variables you want to take out the houses after the
,
?– Maurício Z.B
When running the code I have the following result: Brutus' BMI and : 36.034969 To stay with the ideal Imc Brutus must lose 37.000000 kg 0.000000The Olivia’s BMI and : 14.527376 To stay with the ideal Imc Olivia must gain 12.000000 kg 0.000000
– Leandro Souza
I wanted to get rid of these 0.000000 after the 37.000000 kg, so that the result is : 36.034969 To get the ideal Imc Brutus must lose 37.000000 kg Olivia’s BMI and : 14.527376 To get the ideal Imc Olivia must gain 12.000000 kg
– Leandro Souza
I will elaborate the answer @Leandrosouza
– Maurício Z.B