Write a program in C that prompt the user to enter temperature in either degrees Celsius or Fahrenheit. These program then computes to a different unit. Use function.
using namespace std;
int main()
{
float Temp_in_deg,Temp_in_F;
int Choice=0,Flag=1;
while(Flag)
{
cout<<"\n\n\nSelect -> Press 1 for Deg. to Farenhite Conversion";
cout<<"\nSelect -> Press 2 for Farenhite to Deg. Conversion";
cout<<"\nSelect -> Press 0 to quit";
cout<<"\nEnter Choice = "; cin>>Choice;
if(Choice ==0) exit(0);
if(Choice ==1)
{
cout<<"\n\nEnter Temp. in deg. C = "; cin>>Temp_in_deg;
Temp_in_F = ((9*Temp_in_deg)/5) + 32;
cout<<"\n"<<Temp_in_deg<<" deg. C = "<<Temp_in_F<<" deg. F";
}
if(Choice == 2)
{
cout<<"\n\nEnter Temp. in deg. F = "; cin>>Temp_in_F;
Temp_in_deg = (5*(Temp_in_F - 32))/9;
cout<<"\n"<<Temp_in_F<<" deg. F = "<<Temp_in_deg<<" deg. C";
}
}
}
Comments
I really appreciate you for your work. I give five stars
Leave a comment