Top.Mail.Ru
The C++ Community's Journal -- Day
? ?
The C++ Community's Journal -- Day [entries|friends|calendar]
The C++ Community

[ userinfo | livejournal userinfo ]
[ calendar | livejournal calendar ]

New to community, learning c++, need help [13 Sep 2003|12:53pm]
#include 
using std::cout;
using std::cin;
using std::endl;

int main() {
int start;
float fTemp;
float cTemp;
    cout << "Enter 1 for F to C" << endl;
    cout << "Enter 2 for C to F" << endl;
    cin >> start;
    switch (start) {
    case 1:
        cout << "Enter the Fahrenheit Temperature" << endl;
        cin >> fTemp;
                cTemp = (5 / 9 * fTemp) + 32;
        cout << "The Celsius Temperature is " << cTemp << endl;
        system ("PAUSE");
        return 0;
    case 2:
        cout << "Enter the Celsius Temperature" << endl;
        cin >> cTemp;
                fTemp = (9 / 5 * cTemp) - -32;
        cout << "The Fahrenheit Temperature is " << fTemp << endl;
        system ("PAUSE");
        return 0;
        }
}


could someone tell me why the output for cTemp is always 32 and the output for fTemp is always cTemp + 32??

thanks :) (I'm fairly new to c++, any help would be much appriciated)
5 comments|post comment

navigation
[ viewing | September 13th, 2003 ]
[ go | previous day|next day ]
Image