c++

c++

c++

Sunday, 14 September 2014

Temperature Conversion


Conversion of Fahrenheit to Celsius  

#include<iostream.h>
#include<conio.h>


void main()
{
clrscr(); //to clear the screen
float temp,res;
int choice;
cout<<"Temperature Conversion"<<"\n\n   1.Fahrenheit to Celcius";
cout<<"\n   2.Celcius to Fahrenheit\n\nEnter your choice:";
cin>>choice;


switch(choice)
{
case 1: 
{
    cout<<"\nEnter temperature in Fahrenheit:";
    cin>>temp;
    res=(temp-32)/1.8;
}
break;
case 2: 
{
    cout<<"\nEnter temperature in Celcius:";
    cin>>temp;
    res=(temp*1.8)+32;
}
break;
}


cout<<"\nConverted Temperature="<<res;
getch();
}

No comments:

Post a Comment