Please I need help to write this program by using C The form

Please I need help to write this program by using C++.

The formula for converting a temperature from Fahrenheit to Celsius is C =5/9(F - 32) where F is the Fahrenheit temperature. Write a function named celsius that accept 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 display a table of the Fahrenheit temperature 0 through 20 and their Celsius equivalents.

Solution

Temp.cpp

#include <iostream>
#include <iomanip>
using namespace std;
double celsius (double fahrenheit);
int main()
{
for(double i=0; i<=20; i++){
       double c = celsius (i);
       cout<<fixed<<setprecision(2)<<\"Fahrenheit Temparature: \"<<i<<\" Celsius Temparature: \"<<c<<endl;
       }

return 0;
}

   double celsius (double fahrenheit){
       double celsius = ( 5 /(double) 9 ) * ( fahrenheit - 32 );
       return celsius;
    }

Output:

Fahrenheit Temparature: 0.0 Celsius Temparature: -17.78
Fahrenheit Temparature: 1.0 Celsius Temparature: -17.22
Fahrenheit Temparature: 2.0 Celsius Temparature: -16.67
Fahrenheit Temparature: 3.0 Celsius Temparature: -16.11
Fahrenheit Temparature: 4.0 Celsius Temparature: -15.56
Fahrenheit Temparature: 5.0 Celsius Temparature: -15.00
Fahrenheit Temparature: 6.0 Celsius Temparature: -14.44
Fahrenheit Temparature: 7.0 Celsius Temparature: -13.89
Fahrenheit Temparature: 8.0 Celsius Temparature: -13.33
Fahrenheit Temparature: 9.0 Celsius Temparature: -12.78
Fahrenheit Temparature: 10.0 Celsius Temparature: -12.22
Fahrenheit Temparature: 11.0 Celsius Temparature: -11.67
Fahrenheit Temparature: 12.0 Celsius Temparature: -11.11
Fahrenheit Temparature: 13.0 Celsius Temparature: -10.56
Fahrenheit Temparature: 14.0 Celsius Temparature: -10.00
Fahrenheit Temparature: 15.0 Celsius Temparature: -9.44
Fahrenheit Temparature: 16.0 Celsius Temparature: -8.89
Fahrenheit Temparature: 17.0 Celsius Temparature: -8.33
Fahrenheit Temparature: 18.0 Celsius Temparature: -7.78
Fahrenheit Temparature: 19.0 Celsius Temparature: -7.22
Fahrenheit Temparature: 20.0 Celsius Temparature: -6.67

Please I need help to write this program by using C++. The formula for converting a temperature from Fahrenheit to Celsius is C =5/9(F - 32) where F is the Fahr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site