NyxGrimlock

conversion

Oct 27th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. //
  2. //  Program to convert temperature from Celsius degree
  3. //  units into Fahrenheit degree units:
  4. //  Fahrenheit = Celsius * (212 - 32)/100 + 32
  5. //
  6. #include <cstdio>
  7. #include <cstdlib>
  8. #include <iostream>
  9. using namespace std;
  10.  
  11. int main(int nNumberofArgs, char* pszArgs[])
  12. {
  13.     // enter the temperature in Celsius
  14.     int celsius;
  15.     cout << "Enter the temperature in Celsius:";
  16.     cin >> celsius;
  17.    
  18.     // calculate conversion factor for Celsius
  19.     // to Fahrenheit
  20.     int factor;
  21.     factor = 212 - 32;
  22.    
  23.     // use conversion factor to convert Celsius
  24.     // into Fahrenheit values
  25.     int fahrenheit;
  26.     fahrenheit = factor * celsius/100 + 32;
  27.    
  28.     // output the results (followed by a NewLine)
  29.     cout << "Fahrenheit value is:";
  30.     cout << fahrenheit << endl;
  31.    
  32.     // wait until user is ready before terminating program
  33.     // to allow the user to see the program results
  34.     system("PAUSE");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment