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 trialZach Liston
2,134 PointsFunctions 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
42,016 PointsImplement 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
apps curry
846 PointsIt looks like a bug .... the answer is correct, still its not marking it as correct answer ... bummer :-(
Travis Coats
15,058 PointsI was just stuck on this as well. It is a bug.
zhou su
1,252 Pointsfloat addTwo (float a, float b) { return a + b ;} I get this correct
Serafina de Piro d'Amico Inguanez
220 PointsFor me it's right... Maybe you missed the semi colon? I did that initially.
Zach Liston
2,134 PointsZach Liston
2,134 PointsIt still says that it is incorrect. Is there a bug?
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherThe above answer is right. Some recent changes to challenge broke it. Sorry about the inconvenience but it should work now.