Degrees - Where is cel assigned a value?


#1

I have no problem getting the program degrees to run and by changing the line “freezeInC = 0” to “freezeInC = 100” and swapping freezes for boils in the printf statement I am able to get the correct result. But I don’t see where the value is assigned to the variable cel.

thanks

[code]#include <stdio.h>

float fahrenheitFromCelsius(float cel)
{
float fahr = cel * 1.8 + 32.0;
printf("%f celsius is %f degrees Fahrenheit\n", cel, fahr);
return fahr;
}

int main(int argc, const char * argv[])
{float freezeInC = 100;
float freezeInF = fahrenheitFromCelsius(freezeInC);
printf(“Water boils at %f degrees Faherenheit\n”, freezeInF);
return 0;
}
[/code]


#2

cel is just the name that your fahrenheitFromCelsius() function uses to refer to a number it was handed by the function that called it.

When main() calls your function, it passes in a value of 100 that it knows as “freezeInC”. The fahrenheitFromCelsius() function receives this value, but refers to it by a different name, “cel”.

Specifically, the definition of your fahrenheitFromCelsius(float cel) function specifies “take the first argument to this function and store it in a new local variable called “cel”.”

Does that help?


#3

Yes it does. Thanks.