Functions

Can someone help me with this please?


Write two functions, one of which returns the Fahrenheit value of a Celsius temperature, and another that does the opposite. Use a separate file for headers and functions.

Use the two functions to write a temperature converter. The converter should ask for a temperature, then a scale, then display the converted result.

The converter code should be in a separate file from the functions, so you'll end up with three files: A header file for the functions (i.e. temp_functions.h), the functions themselves (temp_functions.cpp), and the converter program (temp_converter.cpp).

Print and turn in your code and a sample run of the program.


Thank you in advance for your help.


Here is a function that "returns the Fahrenheit value of a Celsius temperature":
1
2
3
4
int GetFreezingPointOfWaterInFahrenheit()
{
    return 0+32; //converts 0 degrees Celcius to 32 degrees Fahrenheit
}

And here is a function "that does the opposite":
1
2
3
4
int GetFreezingPointOfWaterInCelcius()
{
    return 32-32; //converts 32 degrees Fahrenheit to 0 degrees Celcius
}
Thanks LB,

But I need to include the header file and do the implementation. What's your input?

#include <iostream>
Last edited on
Alternatively you could enter the temperature in k ( kelvin) and then subtract 273.16 to get C° and subtract 460 to get F°.
Topic archived. No new replies allowed.