return

Many functions return a value when they complete execution. You know what type of data a function will return by the type that precedes the function name. (If a function does not return anything, its return type is void.)

Create a new C Command Line Tool named Degrees. In main.c, add a function before main() that converts a temperature from Celsius to Fahrenheit. Then update main() to call the new function.

#​i​n​c​l​u​d​e​ ​<​s​t​d​i​o​.​h​>​

f​l​o​a​t​ ​f​a​h​r​e​n​h​e​i​t​F​r​o​m​C​e​l​s​i​u​s​(​f​l​o​a​t​ ​c​e​l​)​ {​ ​ ​ ​ ​f​l​o​a​t​ ​f​a​h​r​ ​=​ ​c​e​l​ ​*​ ​1​.​8​ ​+​ ​3​2​.​0​;​ ​ ​ ​ ​p​r​i​n​t​f​(​"​%​f​ ​C​e​l​s​i​u​s​ ​i​s​ ​%​f​ ​F​a​h​r​e​n​h​e​i​t​\​n​"​,​ ​c​e​l​,​ ​f​a​h​r​)​;​ ​ ​ ​ ​r​e​t​u​r​n​ ​f​a​h​r​;​ ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.