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 trialAna Puente
Courses Plus Student 149 PointsI'm having a hard time understanding the 'Functions' logic. I need help. Site won't let me go back to re-watch video.
I'm not sure if I'm defining my values correctly and how to implement the function.
int sum (float x, float y);
int main()
{
x = 25;
y = 25;
printf ("sum = %d", sum (x,y));
return 0;
}
int sum (float x, float y)
{
return x + y;
}
1 Answer
J.D. Sandifer
18,813 PointsGloria's right: Most of the challenges actually ask for very little code. They're just to make sure you understand the one or two new concepts being presented in the preceding video. Here's an answer:
float addTwo(float x, float y) { // the return type and function name need to be "float" and "addTwo"
return x + y; // otherwise this is just like your last four lines of code
}
Gloria Dwomoh
13,116 PointsGloria Dwomoh
13,116 PointsAre you trying to solve the challenge? If yes the errors you get are mostly because you are not following what it is asking you. It starts by saying "Implement a function named "addTwo" that returns the sum of two floats." your function is not named addTwo and there are other things that need to be fixed. Try reading the challenge again and if you get stuck repost your new code. You can rewatch the lesson..try accessing it from here http://teamtreehouse.com/library/objectivec-basics