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 trialMichael Mills
3,233 PointsFunctional Programming C Challenge
I am not sure what I am doing wrong here. I have spent about an hour and a half trying to figure this out. Please help or give me a hint at what I need to be looking at. Getting an error in Xcode that says redefinition of 'addTwo'
float addTwo(float a, float b) { float boo = 3.1465; float bee = 1.1689; printf("The sum is %f\n", addTwo(boo, bee)); return 0; }
float addTwo(float a, float b) { return a + b; }
4 Answers
Eleisha Cooke
287 PointsI went back and looked at the challenge. I struggled with this question for awhile too, until I realized that they ONLY wanted the implementation of the function. You're giving more than they ask for, but you have the correct answer in there:
float addTwo(float a, float b) {
return a + b;
}
Good luck!
Jason Anello
Courses Plus Student 94,610 PointsIf you submitted both of those lines together then it would look like you're attempting to redefine the function. The first line of your code defines the function but then you're attempting to define it to be something else in your second line of code.
It turns out that your second line of code: float addTwo(float a, float b) { return a + b; }
is what they're looking for. It accepts two arguments a
and b
and it returns the sum of those two arguments a + b
Eleisha Cooke
287 PointsWhat was the quiz question?
Michael Mills
3,233 PointsThank you for your replies!! I appreciate it!