C++ Program for temperature conversion which converts fahrenheit to celcius or celcius to fahrenheit depending upon user's choice

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

void main()
{
clrscr(); //to clear the screen
float temp,res;
int choice;
cout<<“Temperature Conversion”<<“nn   1.Fahrenheit to Celcius”;
cout<<“n   2.Celcius to FahrenheitnnEnter 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(); //to stop the output screen
}

Leave a Comment

Your email address will not be published. Required fields are marked *