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 trialY. Kravets
10,350 PointsWhat am I doing wrong?
I keep getting the following message: "Bummer! The function does not appear to be returning the correct value. Is the return type a float?"
As you can clearly see I have defined the resulting variable to be a float type - what am I doing wrong?
int addTwo(float a, float b)
{
float sum;
sum = a + b;
return sum;
}
5 Answers
Juan Martinez
1,031 PointsIf this is from the question on the quiz after the video then the answer should look like this
float addTwo(float a, float b);
float addTwo(float a, float b) { float sum; sum = a + b; return sum; }
the float at the beginning of the function is saying that the function will be returning a float value
alex novickis
34,894 Pointsask a question get a question ?
int addTwo(float a, float b) <---- what is the purpose of int here
alex novickis
34,894 PointsYou have "int" at beginning of function definition this specifies a return type
is the caller of this function expecting an int ?
Y. Kravets
10,350 PointsI was under impression that this is how you define a function. Am I wrong?
Y. Kravets
10,350 PointsNo it does not, but whenever I specify ```int addTwo(float a, float b)''' it doesn't work either, which is why I am a bit lost.