Monday 4 February 2013

IT series Control Structure Part 5:

Conversion of temperature:

void main()
{
char a;
cout<<"Enter C for Celcius to Farenhiet:\nEnter F for farenheit to celcius\n";
cin>>a;
if(a=='C')
{
int b;
cout<<"Enter the temprature in celcius: ";cin>>b;cout<<"You enter the Celcius temprature as:"<<b<<"C"<<endl;
float bb;
bb=(9.0/5.0)*b+32;
cout<<"This is the temprature in Farenheit:"<<bb<<endl;
}
else
{
int b;
cout<<"Enter the temprature in Farenheit: ";cin>>b;cout<<"You enter the farenheit temprature as:"<<b<<"F"<<endl;
float bb;
bb=((b-32.0)*(5.0/9.0));
cout<<"This is the temprature in Celcius:"<<bb<<endl;
}
}

No comments:

Post a Comment

Comments please: