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

Zach Liston
Zach Liston
2,134 Points

Functions Code Challenge

Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments and return a float which is the sum of the two arguments passed to the function. (No need to write the main function just write out the implmentation for the addTwo function)

" float addTwo (float x, float y);

float x = 5.55; float y = 0.11;

float addTwo (float x, float y) { return x + y; } "

5 Answers

Stone Preston
Stone Preston
42,016 Points

Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments and return a float which is the sum of the two arguments passed to the function.

you are doing more than what is asked for. all you are required to do is write the function, nothing more.

float addTwo (float x, float y) { return x + y; }

is correct, however you dont have to define the prototype or any other variables. all you need is the function definition which is your last line

Zach Liston
Zach Liston
2,134 Points

It still says that it is incorrect. Is there a bug?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

The above answer is right. Some recent changes to challenge broke it. Sorry about the inconvenience but it should work now.

It looks like a bug .... the answer is correct, still its not marking it as correct answer ... bummer :-(

I was just stuck on this as well. It is a bug.

float addTwo (float a, float b) { return a + b ;} I get this correct

For me it's right... Maybe you missed the semi colon? I did that initially.