C++ Program For Temperature Conversion Celsius To Fahrenheit And Vice Versa Using Switch Case

Problem :- Write A Program For Temperature Conversion Celsius To Fahrenheit  And Vice Versa Using Switch Case .

Logic :- For Convert Temperature we use Formula's are given Below
Celsius To Fahrenheit :-

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

Fahrenheit To Celsius :-

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

Solution :-

#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"1. For Celsius To Fahrenheit. \n";
cout<<"2. For Feh 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;
}
}

Output:-

1. Celsius To Fahrenheit

2.Fahrenheit To Celsius

No comments:
Write comments

Recommended Posts × +