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

Bradley Maskell
Bradley Maskell
8,858 Points

Function quiz

In the video where he talks about functions, he never uses a float. He uses int. It tells you not to enter in code for main, but the functions is initialized above main and then the code for the function is written outside of main and then added back into main. What I am supposed to do with this?

2 Answers

Hi Bradley,

I think you're referring to the funky_math function 2 videos back?

The statement above main was the function declaration. What was written below the main function was the function definition or the function implementation. What you were referring to as the code for the function. Then inside the main function the funky_math function was called and 2 int arguments were passed in.

So you have the function declaration above main, the function implementation below main, and you call the function inside main.

The challenge only wants the implementation of the function, none of the other stuff. This is the part that you see below the main function.

Instead of using the int data type you will use the float data type instead.

Let me know if you're still stuck.

Bradley Maskell
Bradley Maskell
8,858 Points

This is what I have so far.

int addTwo(float a, float b){

float a = 224.54; float b = 32.44;

int sum = addTwo(a + b);

return sum; }

I'm not really sure what i'm doing wrong here.

You're doing too much inside the function.

You don't want to call the function inside the function. You only need to return the sum of the 2 arguments passed in.

Also, the return type should be a float as well.

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