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

Can't past the Functional C Programming challenge

I simply don't know how to complete it. Don't see any relation with the class.

Hi Basilio,

Were you able to get started at all?

Yes, I just have the challenge left, the one with the functions and I don't understand the challenge.

1 Answer

If you go back 2 videos to this one: http://teamtreehouse.com/library/objectivec-basics/functional-programming-in-c/functions

And review it starting from 1:44 it shows you almost exactly what you need to do for this challenge. It may be good for you to review this part if you don't have any idea where to begin on this.

Keep in mind that the challenge does not want a complete program with a function declaration, the main function, and then a function definition at the bottom. It only wants the function definition or the implementation of the function.

Still don't understand what to do. In the video explain one thing, that explanation doesn't work for me in the challenge.

Ok, so if you look at the 3:00 mark in that function video you will see at the bottom that the instructor wrote the implementation of the funky_math function.

int funky_math(int a, int b) {
    return a + b + 343;
}

That's the definition or the implementation of the function. This function has 2 parameters that are int's and it also returns an int. The return value is the sum of the 2 arguments passed in plus 343.

The challenge wants you to do something very similar to this but you need to change each part to what the challenge is requesting. You want to change the data types, the function name, and the return value.

Post what code you have if you're still having trouble.

I'm trying the following:

float addTwo (float a, float b) { return a + b; }

not working

int addTwo (float a, float b) { return a + b; }

not working

float addTwo (float a, float b) { return float a + float b; }

not working

int addTwo (float a, float b) { float tree = 25.5; float house = 30.5; return a + b; }

not working

The very first one is perfect and will pass the challenge.

Thanks for hanging in there and figuring it out!

If the first one is not passing for you then I would try refreshing the challenge and pasting it back in.

The first one doesn't work. Try to check the challenge.

I just checked it again and it works. You may be having a challenge problem. Did you try refreshing the challenge?

This is passing for me:

float addTwo (float a, float b) {
  return a + b;
}

I tried it twice.

I guess that not refreshing it was my problem, because now it works. BIG THANKS :D Now I have more reason to stay at Treehouse.

You're welcome! Glad you got it working.

It seems to be rare and I don't know if this is what happened to you but occasionally a correct answer will not pass the challenge. I think it's happening when you start off with a wrong answer and then correct it. What I would do whenever you think this is happening is to copy your code, then refresh the page and paste it back in and see if it passes.