Monday, August 15, 2011

Fahrenheit to Celsius

Problem: Convert given temperature from Fahrenheit to Celsius.


Algorithm:
1. Prompt for temperature in Fahrenheit.
2. Use appropriate formula to calculate its equivalent in Celsius.
3. Display the result.

Source Code:
#include<iostream>
#include<iomanip>
#include<conio.h>
using namespace::std;
int main(void)
{
double F;                    //for Fahrenheit
        double C;                   //for Celsius
cout<<"Enter temperature: ";
cin>>F;
C= 0.56 * ( F-32 );                 //formula for conversion
cout<<showpoint<<fixed;
cout<<setprecision(1);        //setting precision up to 1 decimal place
cout<<F<<"°F is equal to "<<C<<"°C"<<endl;
getch();                             //precaution for blinking screen
return 0;
}

0 response(s):

Respond to this Post

Your participation is appriciated...