This C++ Program performs Celsius to Fahrenheit conversion. The program reads the temperature in Celsius, multiplies the temperature in Celsius by 9 / 5 and adds 32 to obtain temperature in Fahrenheit.
Here is source code of the C++ program which performs Celsius to Fahrenheit conversion. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C++ program to perform celsius to fahrenheit conversion
*/
#include<iostream>
using namespace std;
int main()
{
float fahrenheit, celsius;
cout << "Enter the temperature in Celsius : ";
cin >> celsius;
fahrenheit = (celsius * 9.0) / 5.0 + 32;
cout << "The temperature in Celsius : " << celsius << endl;
cout << "The temperature in Fahrenheit : " << fahrenheit << endl;
return 0;
}
$ g++ main.cpp $ ./a.out Enter the temperature in Celsius : -40 The temperature in Celsius : -40 The temperature in Fahrenheit : -40
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
Next Steps:
- Get Free Certificate of Merit in C++ Programming
- Participate in C++ Programming Certification Contest
- Become a Top Ranker in C++ Programming
- Take C++ Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Related Posts:
- Apply for Information Technology Internship
- Apply for C++ Internship
- Buy C++ Books
- Practice Computer Science MCQs
- Buy Programming Books