在计算表达式后,不会将值赋给变量

时间:2018-04-29 08:46:00

标签: c++

每当我输入Temp时,Cel的值保持为零,为什么表达式不存储值呢?

#include<iostream>

using namespace std;

int main(){
    float Far, Cel, Temp;
    char choice;

    cout << " To convert from Celcius to Farenheit, press 'f' for opposite 'c': "<<endl;
    cin >> choice;

    cout << "Enter Temperature: " << endl;
    cin >> Temp;

    if(choice == 'f' || choice == 'F'){
            Far = (Temp*(9/5))+32;
            cout <<  "Temperature in Farenheit is: " << Far << endl;
    }
    else if(choice == 'c' || choice == 'C'){
            Cel = (Temp - 32) * (5/9);
            cout << "Temperature in Celcius is: " << Cel << endl;
    }

    return 0;
}

0 个答案:

没有答案