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 trialRodrigo Chousal
16,009 PointsI don't understand these instructions.
Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments and return a float which is the sum of the two arguments passed to the function. (No need to write the main function just write out the implmentation for the addTwo function).
Can someone give me the code needed to pass this challenge and explain as well? Please!
1 Answer
Travis Neiderhiser
1,027 Points//define the function that returns a float with two float arguments
float addTwo(float a, float b) {
//return the sum by adding the two arguments together.
return a + b;
}
First you define the function with the type of arguments that you will be passing into the function. Once in the function they want us to return the sum of the two arguments. So we return the sum by adding the two together.