C - Remove item from result

2

How do I remove 0.00000 prints in the response of this program after the idealBrutus and idealOlivia functions are called in the main function?

I noticed that if, for example, you change line 59 from the original to:

printf ("%s", idealBrutus (imcBrutus,pBrutus, hBrutus, strBrutus));

I will get one ( null ) after the function is idealBrutus to 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));

}
    
asked by anonymous 19.08.2018 / 01:17

2 answers

1
  

I was seeing your code and I noticed that you had a question in   

19.08.2018 / 02:04
0

No printf() just put the following formatting: "%.2f" . The number indicates how many houses you want to display.

    
19.08.2018 / 01:57