C++ Program for temperature conversion which converts Fahrenheit to Celcius or Celcius to Fahrenheit depending upon user’s choice

Program

#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

error: Alert: Content is protected!!