Saturday 5 July 2014

Program to convert temperature Celsius to Fahrenheit and vice versa with menu option.


//Temperature conversion
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int choice;
float temp,result;
char ch;
do
{
cout<<"\n"<<"1.Fahrenheit to Celsius:";
cout<<"\n"<<"2.Celsius ti Fahrenheit:";
cout<<"\n"<<"Choose your choice - 1 OR 2:";
cin>>choice;
if(choice==1)
{
cout<<"Enter the temprature in Fahrenheit:";
cin>>temp;
result=(temp-32)/1.8;
cout<<"Temprature in Celsius is=";
cout<<result;
}
else
{
cout<<"Enter the temprature in Celsius=";
cin>>temp;
result=(1.8*temp)+32;
cout<<"Temprature in Fahrehnheit is=";
cout<<result;
}
cout<<"\n"<<"Do you want to continue - Y OR N=>";
cin>>ch;
}
while(ch=='y'||ch=='Y');

}

No comments:

Post a Comment