Author Topic: Temp conversion  (Read 3999 times)

louiecerv

  • Moderator
  • User
  • *****
  • Posts: 85
Temp conversion
« on: November 22, 2005, 01:47:49 AM »
Study this code sample:

Code: [Select]

#include <iostream>

using namespace std;

int main()
{
    cout << "-- FAHRENHEIT TO CELSIUS CONVERSION --" << endl;
    cout << "Temperature in degrees Fahrenheit:  ";
    double fahrenheit, celsius;
    cin >> fahrenheit;
    celsius = (5.0/9.0) * (fahrenheit - 32.0);
   
    cout << endl << "in degrees celsius: " << celsius << endl;
   
    system("PAUSE");
    return 0;
}
Analyze. Design. Develop. Debug. Deploy. Maintain.

louiecerv

  • Moderator
  • User
  • *****
  • Posts: 85
Temp conversion
« Reply #1 on: November 28, 2005, 02:28:39 PM »
Highlights:
avoiding integer division
making correct choice of datatype
Analyze. Design. Develop. Debug. Deploy. Maintain.