Fahrenheit to Celsius Program [Functions] - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Fahrenheit to Celsius Program [Functions]

C.SkyC.Sky Posts: 7Member
Im trying to write a function named celsius that accepts a Fahrenheit temperature as an argument. The function should return the temperature, converted to celsius. Also i have to demonstrate the function by calling it in a loop that displays a table from 0 through 20 and the celsius equivalents. This is what ive got so far.. any help will be appreciate it.

// This program will Accept Fahrenheit as
// an argument and return it as Celsius
// from 0 to 20 using a loop.

using namespace std;

// Function Prototypes
double celsius(double);

int main()
// Set Precision

cout << setprecision(12) << fixed << showpoint;

// Make the chart

cout << "Farenheit" << setw(12) << right << "celsius";
cout << "

// Use The Loop 0 - 20
for (double f = 0; f <= 20; f++)
cout << setw(10) << right << f
<< setw(12) << right << celsius(f)
<< endl;
return 0;

//* Definiton of function celsius *
//* This function accepts fahrenheit *
//* as an agument and returns it as *
//* celsius *

double celsius(double f)
double c = (5.0/9.0) * (f - 32);

return c;


Sign In or Register to comment.