Question

C++ Code needed    Celsius Temperature Table The formula for converting a temperature from Fahrenheit to...

C++ Code needed

   Celsius Temperature Table
The formula for converting a temperature from Fahrenheit to Celsius is
C =5/9(F -32)
where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function
named celsius that accepts a Fahrenheit temperature as an argument. The function
should return the temperature, converted to Celsius. Demonstrate the function by
calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
using namespace std;

double FtoC(double F){
    return (5.0/9.0)*(F-32);
}

int main()
{
    cout<<"F\tC"<<endl;
    for(int i = 0;i<=20;i++){
        cout<<i<<"\t"<<FtoC(i)<<endl;
    }
    return 0;
}

Output :

C F 10 1 2. 3 14 15 16 7 18 19 10 -17.7778 -17.2222. -16.6667 -16.1111 -15.5556 -15 -14.4444 -13.8889 -13.3333 -12.7778 -12.2

Note: Please comment below if you have any doubts. upuote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
C++ Code needed    Celsius Temperature Table The formula for converting a temperature from Fahrenheit to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT