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

I don't know what i'm doing wrong with the task of writing the first float function.

it's dealing with writing the first function in the challenge section of this course.

What's your current code that's not passing?

did you get that?

7 Answers

You're simply missing the return statement in the body of the function. Since the name of this function is "addTwo", we can assume that we'll be adding the two arguments together. Therefore, that's what you must return:

float addTwo(float a, float b) {

    return a + b;
}

That should work for you. I didn't want to post the answer, but I hope you'll learn from the explanation :)

float addTwo (float a, float b);

it's asking to write a function that implements the addTwo, where two floats are added together and the sum is returned.

I did get that, was just looking at the Code Challenge :)

Ok, so if that's all the code you have, I believe you're forgetting the return statement. Try to implement that, and let me know if you still need help :)

I thought it was just asking me to give the implantation, like one line?

I think in this case, is simply wants the shell of the function, meaning the return type, the name, the arguments it will accept, and what it will return. Not 100% on that, but to pass the challenge you're required to code those 4 things.

Did you pass it?

this is odd, i don't think I've even been so cerflazeled, not since i drank too much, and told everyone that I was a crackhead. Thanks.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

This helped me on that challenge,

returnType functionName(dataType parameterOne, dataType parameterTwo) {

return something;

}

still nothing!

THANK YOU