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 trial

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

Is my code wrong? In Xcode works

int main() { float addTwo(float a,float b);

float a = 2.5; float b = 2.5; float result = addTwo(a,b); printf("%f \n", result); return 0; }

float addTwo(float a,float b) { return a + b ; }

3 Answers

Stone Preston
Stone Preston
42,016 Points

the challenge says not to include main and only implement the function. your code is correct, but the challenge only wants the implementation.

all you need is

float addTwo(float a,float b) { return a + b ; }

i should have looked at the question :-P

addtwo should be declared before int main, have a look back over the videos if unsure.

Got it, sorry but my english is not perfect. If youΒ΄re thinking of translating the courses to Portuguese ( portugal, brasil) let me know :) Apart of that ... all fantastic!