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

Need help with challenge on stage two

Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments. It should add the two arguments together, and return the result. (No need to write the main function. Just write out the implementation for the addTwo function.)......please provide an example that I can follow.

3 Answers

Aaron Ward
Aaron Ward
2,872 Points

I could use some help on this one as well... Here is what I got

float addtwo ( float a,  float b);
int main()
float a =3;
float b =6;
float result = addtwo (a, b);
printf("addtwo %f\n", result);
return 0;

float addtwo (float a, float b) {
return a + b;
Stone Preston
Stone Preston
42,016 Points

all you need to do is implement the function. 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.

Aaron Ward
Aaron Ward
2,872 Points

thank you for taking the time to help Stone Preston