# When did we assign anything to "cel" in the example?

#1

Im new so bear with me

Im just curious as to how this little program created any value for â€ścelâ€ť in the temperature conversion example? I get the program but I donâ€™tâ€¦

float fahrenheitFromCelsius(float cel)
lastTemperature = cel;
float fahr = cel * 1.8 + 32.0;
printf("%f Celsius is %f Fahrenheit\n", cel, fahr);
return fahr;

cel was never defined. or is cel the return of the function fahrenheitFromCelsius?
And then does that make fahr and cel equal?

maybe Iâ€™m getting lost in the function

float fahrenheitFromCelsius(float cel)

Float (means its going to return a float) Fahrenheit (name of function) (float cel) is what? another return?

My mind keep going backwards and forewards., maybe Im just not cut out for this. Even the classical music playing in the background isnâ€™t helping me.

Thanks for all the help!
Josh

printf("%

#2

Just saw the reply below! I posted prematurely and the example below helped a lot!

This forum is great, I just need to look before I type!

Thanks again everyone
Josh

#3

I would be very interested in the response but there are only the posts by JmacUSAF.

#4

Take a look at â€śWhere is cel assigned a value?â€ť

Here is the answer posted there:
"Where is cel assigned a value?

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?"

#5

hi Rick, etc.

thanks for the explanation, but i thought freezeInC had a value of 0, not 100? that is what the code says in the exercise. where did 100 come from? also, are you saying that the main â€śdefinesâ€ť the argument of fahrenheitFromCelsius first, and THEN when the function above it uses it, an abbreviation word is used (could be any word, it is arbitrary) to replace freezeInC? if so, why do a replacement, that seems confusing for beginners (since it is not explained).

maybe i am missing something, but i also donâ€™t see why cel was used in the function and how it relates to the main, when the function is called. thanks in advance for any help.

#6

Itâ€™s an old thread I know but sometimes the examples are not well explained.