previous | start | next

Example 1



    1   // File: celsius.cpp
    2   // Description: Converts Fahrenheit to Celsius
    3   // Author:
    4   // Last Modified: 07 Sep 05
    5   #include <iostream>
    6   
    7   using namespace std;
    8   
    9   int main()
   10   {
   11     double f, c;
   12   
   13     cout.precision(2);
   14     cout.setf(ios::fixed);
   15     cout << "Enter fahrenheit temperature: ";
   16     cin >> f;
   17     c = (f - 32.0) * 5.0/9.0;
   18   
   19     cout << "\n" << f << " degrees fahrenheit is equal to " 
   20          << c << " degrees celsius."
   21          << endl;
   22   
   23     return 0;
   24   }
   25   


previous | start | next