Friday, 13 December 2013

C++ Temperature conversion program.

// Temperature conversion program.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float celsius,fahrenheit;
int choice;
choice=0;
cout<<"-----TEMPERATURE CONVERSION--------\n";
cout<<"1. Celsius\n2. Fahrenheit\n";
cout<<"Enter starting temperature choice : ";
cin>> choice;
switch(choice)
{
case 1: //if choice==1 then
        cout<<"Enter temperature in Celsius:";
        cin>> celsius;
        cin.ignore();
        fahrenheit = celsius*9/5+32;
        cout<<""<<celsius<<" degrees Celsius="<<fahrenheit<<" degrees Fahrenheit\n";
        break;

case 2: //if choice==2 then
        cout<<"Enter temperature in Fahrenheit:";
        cin >> fahrenheit;
        cin.ignore ();
        celsius= (fahrenheit-32)*5/9;
        cout<<""<<fahrenheit<<" degrees Fahrenheit ="<<celsius<<" degrees Celsius\n";
        break;

default: //if user enter wrong input choice
         cout<<"Please Enter Proper Choice.."<<endl;

}
getch();
return 0;
}

OUTPUT


No comments:

Post a Comment