C++ celsius to fahrenheit – C++ Program to Convert Temperature from Celsius to Fahrenheit

C++ celsius to fahrenheit: In the previous article, we have discussed C++ Program to Reverse Digits of a Number. In this article, we will see C++ Program to Convert Temperature from Celsius to Fahrenheit.

C++ Program to Convert Temperature from Celsius to Fahrenheit

  • Write a C++ program to convert temperature from celsius to fahrenheit degree.

In this C++ program to convert temperature in Celsius to Fahrenheit, we will first take temperature in Celsius scale as input from user and convert to Fahrenheit scale. To convert Celsius to Fahrenheit we will use following conversion expression:

F =(9/5)*C + 32
where, C is the temperature in Celsius and F is temperature in Fahrenheit.

Points to Remember

  • Fahrenheit temperature scale was introduced around 300 years ago, and is currently used in USA and few other countries. The boiling point of water is 212 °F and the freezing point of water is 32 °F.
  • Celsius is a temperature scale where 0 °C indicates the melting point of ice and 100 °C indicates the steam point of water.

C++ Program to Convert Temperature from Celsius to Fahrenheit Scale

C++ Program to Convert Temperature from Celsius to Fahrenheit Scale

// C++ program to convert temperature from celsius to fahrenheit
 
#include <iostream>
using namespace std;
  
int main() {
    float fahren, celsius;
  
    cout << "Enter the temperature in celsius\n";
    cin >> celsius;
  
    // convert celsius to fahreneheit 
    // Multiply by 9, then divide by 5, then add 32
    fahren =(9.0/5.0) * celsius + 32;
  
    cout << celsius <<"Centigrade is equal to " << fahren <<"Fahrenheit";
      
    return 0;
}

Output

Enter the temperature in celsius
40
40 Centigrade is equal to 104 Fahrenheit

In above program, we first take Celsius temperature as input from user. Then convert it to Fahrenheit using above conversion equation and print it in screen using cout.

The comprehensive list of C++ Programs Examples covered in our pages are very useful for every beginners and experienced programmers. So, make use of these C++ Coding Exercises & hold a grip on the programming language.