C-浮点计算,后面没有任何值

时间:2019-03-22 00:30:16

标签: c calculation

我必须为摄氏和华氏度做一个计算器。

我试图将变量设置为float和double,但没有得到点后面的值。我还在printf中进行了强制转换。

希望您能给我一些提示。

void tabelleCzF(){              /*Funktion für Tabelle Celsius zu Fahrenheit*/
    int celsius;
    int fahrenheit;
    int zaehler = 0;

    celsius = -55;

    while(celsius <= 55){
        fahrenheit = celsius*(9/5)+32;
        printf("%i°C = %.2f°F\t",celsius, (float) fahrenheit);
        celsius ++;
        zaehler ++;
        if (zaehler == 4){
            printf("\n");
            zaehler = 0;
        }   
    }
}

在乔纳森和巴勃罗之后:

void tabelleCzF(){              /*Funktion für Tabelle Celsius zu Fahrenheit*/
    int celsius;
    float fahrenheit;
    int zaehler = 0;

    celsius = -55;

    while(celsius <= 55){
    fahrenheit = celsius*(9.0/5.0)+32.0;
    printf("%i°C = %.2f°F\t",celsius, fahrenheit);
    celsius ++;
    zaehler ++;
        if (zaehler == 4){
            printf("\n");
            zaehler = 0;
        }   
    }
}

0 个答案:

没有答案
相关问题