03/03/2023

C++ Program to Convert Celsius to Fahrenheit And Vice Versa

Write a program in c++ for temperature conversion that gives the user the option of converting Fahrenheit to celsius or celsius to Fahrenheit depending upon the user's choice. For Converting the Temperature of Celsius to Fahrenheit, we are using a given Formula. Write a program in C++ to convert temperature in celsius to Fahrenheit. We have just taken a value or temperature in Celsius or Fahrenheit by the user and put the values in the given formula and print the outcome given by the formula on screen.

C++ Program to Convert Celsius to Fahrenheit And Vice Versa

Here in this problem, we are given three option to the user and the user have to choose any one of the first choices Celsius To Fahrenheit, the second choice Fahrenheit To Celsius and the Last one Exit without testing any one of the queries. C++ program to convert temperature from Fahrenheit to celsius and vice versa. Formula to convert celsius into Fahrenheit.

Temperature Conversion Formula

Celsius To Fahrenheit

Fahrenheit = (Celsius * 9 / 5) + 32;

Fahrenheit to Celsius Table C++

Celsius = (Fahrenheit - 32) * 5 / 9;

Read: C Program to Convert Celsius to Fahrenheit And Vice Versa

C++ Program to Convert Celsius to Fahrenheit And Vice Versa


#include <iostream>
using namespace std;

int main()
{
	/*c++ program to convert Temperature from fahrenheit to celsius and vice versa */

	int a;

	cout << "1. For Celsius To Fahrenheit. \n";
	cout << "2. For Fahrenheit To Celsius. \n";
	cout << "3. For Exit\n\n";

	cout << "Enter Your Choice \n ";
	cin >> a;
	switch (a)
	{
		double cel, feh;
		case 1:
			cout << "Enter The Temperature In Celsius\n";
			cin >> cel;
			feh = (cel *9 / 5) + 32;
			cout << "\nTemperature In Fahrenheit Is = " << feh;
			break;

		case 2:
			cout << "Enter The Temperature In Fahrenheit\n";
			cin >> feh;
			cel = (feh - 32) *5 / 9;
			cout << "\nTemperature In Celsius Is = " << cel;
			break;

		case 3:
			exit(0);

		default:
			cout << "\nEnter The Right Choice \n";
			break;
	}
}


The Output of Convert Celsius to Fahrenheit And Vice Versa


1. Convert Celsius to Fahrenheit

Convert Celsius to Fahrenheit

2. Convert Fahrenheit To Celsius

C++ Program to Convert Celsius to Fahrenheit And Vice Versa

Similar to Convert Celsius to Fahrenheit And Vice Versa


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: