Program 1.2
Program 1.2
2
Write a temperature-conversion program that gives the user the option of converting Fahrenheit to celcius
or celsius to Fahrenheit and depending upon user’s choice carries out the conversion.
#include<iostream.h>
int main()
int choice;
double temp,conv_temp;
cout<<”2.celsius to fahrenheit”<<”\n”;
cin>>choice;
if (choice==1)
cin>>temp;
conv_temp =(temp-32)/1.8;
else
cin>>temp;
conv_temp=(1.8*temp)+32;
}
return 0;
Output:
2. Celsius to Fahrenheit