Advertisement
daixso

Covert Celsius to Fahrenheit

Dec 17th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. /**
  2.  * Convert Celsius to Farenheit
  3.  **/
  4.  
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     //Enter temp in celsius
  14.     cout << "Enter the temperature in Celsius: ";
  15.     int celsius;
  16.     cin >> celsius;
  17.    
  18.     //calculate conversion factor for Celsius to Fahrenheit
  19.     int factor;
  20.     factor= 212-32;
  21.  
  22.     //calculate conversion factor for Celsius
  23.     int fahrenheit;
  24.     fahrenheit= factor * celsius/100 + 32;
  25.  
  26.     //output results
  27.     cout << "\n" << celsius << " in Fahrenheit: " << fahrenheit << "\n";
  28.  
  29.     system("pause");
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement