Question: #include using namespace std; float c _ f ( float ) ; float f _ c ( float ) ; main ( ) { while

#include
using namespace std;
float c_f(float);
float f_c(float);
main()
{
while(1)
{
int ch;
float temp;
cout <<"***Temparature Conversion Program***"<< endl;
cout <<"
1. Celsius to Fahrenheit
2. Fahrenheit to Celsius
3. Exit" << endl;
cout <<"
Enter you choice: ";
cin >> ch;
if(ch==1)
{
cout <<"
**Celsius to Fahrenheit**"<< endl;
cout << "Enter temparature in Celsius: ";
cin >> temp;
if(temp>=0)
cout << "Temparature in Fahrenheit: "<< c_f(temp)<< endl << endl;
else
cout << "Try with a positive number.";
}
else if(ch==2)
{
cout <<"
**Fahrenheit to Celsius**"<< endl;
cout << "Enter temprature in Fahrenheit: ";
cin >> temp;
if(temp>=0)
cout << "Temprature in Celsius: "<< f_c(temp)<< endl << endl;
else
cout << "Try with a positive number.";
}
else if(ch==3)
{
cout <<"
**Thank you for using this program" << endl;
exit(0);
}
else
{
cout<<"Invalid Choice";
}
}
}
float c_f(float celsius)
{
float fahrenheit =(celsius*9.0)/5.0+32;
return fahrenheit;
}
float f_c(float fahrenheit)
{
float celsius =5.0*(fahrenheit-32)/9.0;
return celsius;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!