C++ Program to Perform Celsius to Fahrenheit Conversion - Wisdom Lighter

Tuesday, 22 May 2018

C++ Program to Perform Celsius to Fahrenheit Conversion

C++
  1. 
    /*
  2.  * C++ program to perform celsius to fahrenheit conversion
  3.  */
  4. #include<iostream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     float fahrenheit, celsius;
  10.  
  11.     cout << "Enter the temperature in Celsius : ";
  12.     cin >> celsius;
  13.     fahrenheit = (celsius * 9.0) / 5.0 + 32;
  14.     cout << "The temperature in Celsius    : " << celsius << endl;
  15.     cout << "The temperature in Fahrenheit : " << fahrenheit << endl;
  16.     return 0;
  17. }

Ouput

$ g++ main.cpp
$ ./a.out
Enter the temperature in Celsius : -40
The temperature in Celsius    : -40
The temperature in Fahrenheit : -40

 

No comments:
Write comments