How to convert Fahrenheit to Celsius?
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: How to convert Fahrenheit to Celsius?

1. Junior Member
Join Date
Mar 2017
Posts
6

## How to convert Fahrenheit to Celsius?

How do I write a program that converts asks the user to enter a temperature in Fahrenheit, reads the
entered value, converts it to Celsius using the formula and prints the value to
the console?

Needs to use this: T C=(T F−32)⋅5/9

2. ## Re: How to convert Fahrenheit to Celsius?

use cin >> to obtain the temperature in Fahrenheight (say f as type double), then use cout << to display the converted value

Code:
```double f;
cin >> f;
cout << (f - 32.0) * 5.0 / 9.0 << endl;```
Is this a homework assignment?
Last edited by 2kaud; March 25th, 2017 at 11:43 AM.

3. Junior Member
Join Date
Mar 2017
Posts
6

## Re: How to convert Fahrenheit to Celsius?

Yes a homework and These are are the hardest problems for me

4. ## Re: How to convert Fahrenheit to Celsius?

Have a look at http://forums.codeguru.com/showthrea...ork-assignment so you can get an idea as to the amount of help we'll be able to provide for homework type questions.

5. ## Re: How to convert Fahrenheit to Celsius?

[Thread moved from Visual c++ forum as visual c++ not used]

6. ## Re: How to convert Fahrenheit to Celsius?

Originally Posted by jamsdolpw
Yes a homework and These are are the hardest problems for me
If you are taking a c++ course and have had these exercises set as homework, I don't understand how these could be considered 'hardest problems' as they are quite trivial. What has your instructor covered and what book has been suggested?

Have you actually written yet a c++ program that compiled correctly and was able to be executed OK? if so for what?

7. Member
Join Date
Mar 2017
Posts
105

## Re: How to convert Fahrenheit to Celsius?

Please don't ask homework assignments until you have done enough progress which is satisfactory.
Though you can do it like this:

8. Member
Join Date
Mar 2017
Posts
105

## Re: How to convert Fahrenheit to Celsius?

Code:
Code:
```#include<iostream>
using namespace std;

int main ()
{
double f;
double c;

cout <<"Enter the Farenheit value" << endl;
cin >> f;

c=(f-32)*5/9;
cout << " The Celsius value is:"<< c << endl;

return 0;
}```
Last edited by 2kaud; March 29th, 2017 at 05:41 AM. Reason: Added code tags

9. Member
Join Date
Mar 2017
Posts
105

## Re: How to convert Fahrenheit to Celsius?

Thanks for editing

10. ## Re: How to convert Fahrenheit to Celsius?

[When posting code, please use code tags so that the code is readable. Go Advanced, select the formatted code and click '#'.]

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Click Here to Expand Forum to Full Width