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 trialJonathan Dueck
4,596 PointsWorks in X Code, not in code challenge... Sorta
What am I missing here? Inputting the following into XCode works, as long as I've given values to variables a and b. If I don't define a and b, it doesn't work in either XCode or the code challenge. Thanks!
float addTwo(float a,float b); {
float a = 1;
float b = 2;
float result = a + b;
printf("%f\n",result);
}
2 Answers
Stone Preston
42,016 Pointsyou are supposed to write a function that returns a float and takes 2 floats as parameters. It should return the sum of the 2 parameters passed in. you dont have to assign any values or print anything out. you also have a semicolon where you dont need one.
This should help:
float addTwo(float a, float b) {
return
}
There is a mathematical expression that needs to go after the word return. ill let you figure that out. be sure you end the statement with a semicolon.
Jonathan Dueck
4,596 PointsI was seriously overcomplicating it. Got it now. Thanks!
Stone Preston
42,016 Pointsno problem : )
Stone Preston
42,016 PointsStone Preston
42,016 Pointsthe reason its not working unless you define a and b is probably
float addTwo(float a,float b); {
that semi colon does not go there.