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

have no idea how to do this

10 Answers

Bradan Jackson
Bradan Jackson
20,558 Points

Both arguments should be floats, and it should return a float, so the complete code should be:

float addTwo(float a, float b) {
    return a + b;
}
Bradan Jackson
Bradan Jackson
20,558 Points

You should add your code and the question/challenge that you're having issues with to your discussion.

They explain how to do this in the video prior.

First, enter the type you expect to return and the function name: float addTwo()

Then specify the arguments that the function will be receiving: float addTwo(float a, float b)

Then write what the function should return: { return a + b; }

Your end result should be: returnType functionName(argument1, argument2) { return argument1 + argument2; }

I hope this helps!

thanks you

It didn't work for me, I typed: float addTwo(float a, float b) { return (a + b); }

Bradan Jackson
Bradan Jackson
20,558 Points

This code challenge doesn't appear to be taking the exact answer that I entered to pass, earlier today...

I watched the video on functions again and in the video doug declares two int numbers. Is that required in this challenge? I could see why, but it says not to worry about the main function. I really just don't have any clue.

yeah that's exactly what I typed. My editor doesn't do the color differentials though, is that the problem you think?

Bradan Jackson
Bradan Jackson
20,558 Points

Mine isn't highlighting or accepting the answer, either. I think there's an issue with that challenge currently.

frustrating. I'm moving on for now.

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Some recent changes to challenge broke it. Sorry about the inconvenience but it should work now.