Monday, August 15, 2011

Fahrenheit to Celsius

Problem: Convert given temperature from Fahrenheit to Celsius.

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

Source Code:
using namespace::std;
int main(void)
double F;                    //for Fahrenheit
        double C;                   //for Celsius
cout<<"Enter temperature: ";
C= 0.56 * ( F-32 );                 //formula for conversion
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...