C++ Program To Convert Celsius To Fahrenheit And Vice Versa Using Switch Case
belongs to collection: Switch Case programs in C++ Programming
All Answers
need an explanation for this answer? contact us directly to get an explanation for this answer
#include<iostream>
using namespace std;
int main()
{
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;
}
}
Output:
1. For Celsius To Fahrenheit.
2. For Fahrenheit To Celsius.
3. For Exit
Enter Your Choice
1
Enter The Temperature In Celsius
37
Temperature In Fahrenheit Is = 98.6
need an explanation for this answer? contact us directly to get an explanation for this answertotal answers (2)
using if else instead of switch statement:
need an explanation for this answer? contact us directly to get an explanation for this answer