I am passing a value into a function to convert Celsius to Fahrenheit, but the console prints an error code which brings up nothing when I Google it.
// Function Declarations
float fToC(float degreesF = 32.0);
int main() {
float fahrenheit = 10;
float centigrade = 10;
centigrade = fToC(fahrenheit);
cout << "Freezing Point: " << fToC << "C" << endl;
return 0;
}
// Function Defintions
float fToC(float degreesF) {
float degreesC = ((5.0 / 9.0)*(degreesF - 32));
return degreesC;
}
This prints into the console:
Freezing Point: 00A31627C
What did I do wrong?
It is because you are printing out the function and not centigrade.
cout << "Freezing Point: " << fToC << "C" << endl;
in the console it is showing the memory address of the function.
You should do something like:
cout << "Freezing Point: " << centigrade << "C" << endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With