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

implementing a float function

i am stuck on a challenge

1 Answer

This is what you're looking for:

float addTwo (float x, float y) {
    return x + y;
}

The first part creates a float type function named addTwo. The next part in the parentheses contains the two variables that will be fed into that function. In this case, we need two different float values, so we create two different variables for them. I called them float x and float y, but really, you can name them anything you want. Then the next part will return the summed up value of the two float variables x and y.

For example, if your function implementation looked like this, addTwo (2, 3), it would return a value sum of 5.