Advertisement
int8

Celcius to Fahrenheit C++, commented for newbie

Aug 6th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1.  
  2. // provide access to library
  3. // for console input and output
  4. #include <iostream>
  5.  
  6. // define a scope so as not to
  7. // repeatedly type std::cin etc
  8. using namespace std;
  9.  
  10. // the initial code function
  11. // used upon execution
  12. int main()
  13. {
  14.   // declare decimal integers
  15.   // for Celsius and Fahrenheit
  16.   float c, f;
  17.  
  18.   // take user input from
  19.   // console to variable
  20.   cin >> c;
  21.  
  22.   // calculate the conversion
  23.   f = c * 1.8 + 32;
  24.  
  25.   // print converted temperature
  26.   cout << f;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement