I am in the “Return” section of Chapter 5. I just completed the “Degrees” exercise. I made a mistake in copying the code from the book to my computer. My code looked like this: [code]#include <stdio.h>
float fahrenheitFromCelsius(float cel)
float fahr = cel * 1.8 + 32.0;
printf("%f Celsius is %f Fahrenheit\n");
int main(int argc, const char * argv)
float freezeInC = 0;
float freezeInF = fahrenheitFromCelsius(freezeInC);
printf(“Water freezes at %f degrees Fahrenheit\n”, freezeInF);
I then realized that I forgot to add “, cel, fahr” after “printf(”%f Celsius is %f Fahrenheit\n""
Both builds logged nearly identical output.
With the mistake:
“0.000000 Celsius is 32.000008 Fahrenheit
Water freezes at 32.000000 degrees Fahrenheit”
Without the mistake:
"0.000000 Celsius is 32.000000 Fahrenheit
Water freezes at 32.000000 degrees Fahrenheit
I was hoping someone could explain to me why the program still works and returns (nearly) the correct output even though I did not tell the program what variables to plug into my function. With the mistake, it seems like the Log Navigator would read, "32.00000 Celsius is 32.00000 Fahrenheit.
Thanks in advance.