Answer to Question #287767 in C for Freddie

Question #287767

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.

1
Expert's answer
2022-01-17T00:34:27-0500



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";
		}
	}


}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Fred001
17.01.22, 07:44

I really appreciate you for your work. I give five stars

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS