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 trialAbdelGhafour Mohie
1,876 PointsWhy my code isn't correct ?!
"
int addTwo(float x, float y){ x = 2.5; y = 3.5; float result = x + y; return result; } "
Why isn't this acceptable ?!
2 Answers
Stone Preston
42,016 Points//needs to have a return type of float, not int
int addTwo(float x, float y){
//you dont need to assign values to the parameters
x = 2.5;
y = 3.5;
float result = x + y;
return result;
}
your return type needs to be a float, not an int. you also dont need to assign any values to the parameters x and y. so remove the 2 lines where you assign values to x and y and change your return type from int to a float
AbdelGhafour Mohie
1,876 PointsThanx a lot my friend.