Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Functional Programming in C Functions

functions challenge

can you solve this

Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments. It should add the two arguments together, and return the result. (No need to write the main function. Just write out the implementation for the addTwo function.)

Jacques Vincilione
Jacques Vincilione
17,292 Points

-_- Can you at least post what you're having trouble with?

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,076 Points

Well first and foremost I would simply recommend watching the videos, if you are jumping into a challenge and not knowing what to do, then you may need to slow down and re-watch things.

Now this is simply asking you to write a function that adds two floats together and returns that said value.

I will outline for you how to do this without writing the code itself.

  1. Create a function of the type float with the name addTwo.
  2. Add two parameters (two variables) of the type float to this function
  3. Within the function use the return statement to 'return' the value of the two parameters added together (their sum).

And that is your problem solved above, have fun coding :) If you do not understand anything that was written in the list of instructions above, then you need to begin watching these videos and pay close attention to the parts about writing functions.