lundi 17 décembre 2018

float not working in if else statement (c)

Whenever I try to use a float value in this if else statement it gives me 0 or an incorrect answer. i have used Int for the rest of the code and the rest works fine. This is the first time i have used float in the code and now its not giving me the answer I want. What am i doing wrong here?

float interestrate;

    if (month < 49)
    {
        interestrate = (0.063);
    }
    else if (salary <= 25000)
    {
        interestrate = (0.033);
    }
    else if (salary > 45000)
    {
        interestrate = (0.063);
    }
    else
    {
        interestrate = (0.033+(salaryabovethreshold*0.0000015));
    }

    printf("Interest Rate: %d \n", interestrate);

Aucun commentaire:

Enregistrer un commentaire