Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Functional Programming in C Functions

Brady Sherman
Brady Sherman
3,320 Points

need help with functions

'''C float add_Two (float a,float b) { float a = 22; float b = 45; printf("%f is the total floating",add_Two(a,b)); return 0; } { float add_Two (float a,float b) return a + b; } '''

Says i need to "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."

1 Answer

Treehouse's validation engine requires your function names and variable names to be exact. Name your function addTwo instead of add_Two.

You can't declare variables a and b inside of your function. You're already passing them in as arguments. You're also not returning the sum. You're returning 0 from the function. Make sure you return the sum of the two numbers.

You should also take the printf statement out. Sometimes having extra code can make the validation fail, even if it should succeed.