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

ben spicer
ben spicer
2,774 Points

I am not sure what I am suppose to write for this code. I am not completely sure what I am being asked to do.

int add_two (float a, float b); {

printf("%d", add_two (float a, float b));

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

this is what I have. I am not sure what to do

1 Answer

Stone Preston
Stone Preston
42,016 Points

all you need to do is implement the function. you do not need to declare any variables, you dont need a function prototype. all you need is the function implementation. here is a shell of what your function should look like:

returnType functionName(dataType parameterOne, dataType parameterTwo) {

return something;

}

the challenge tells you it needs to be named add two, it needs to take two arguments (these are your parameters). these arguments need to be of the type float. then you need to return the sum of the parameters. since you are returning the sum of 2 floats your return type needs to be a float.

note that I called the variables inside the parenthesis parameters. When implementing a function, the variables you put inside the ( ) are known as parameters. When calling a function, they are arguments.

ben spicer
ben spicer
2,774 Points

Thanks for the help! Now I am stuck again. float addtwo(float a, float b) {

return a + b; }

I have this now. Im not sure what I am doing wrong.

Stone Preston
Stone Preston
42,016 Points

name the function addTwo, not addtwo:

 float addTwo(float a, float b) {

return a + b;
 }