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, Challenge task - Write a function named "addTwo"

"Write a function named "addTwo" that accepts two float numbers as arguments. The function should also return a float which is the sum of the two arguments passed to the function."

I wrote

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

Amit Bijlani what did I do wrong ? thx!

2 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Nemanja, I'm not Amit, but "The function should return a FLOAT" and you returned an INTEGER - the rest is ok :-)

wow, I was under impression that I always declare function using int name_of_fun, ... thanks!

I fell for that too. It was driving me nuts lol.

Alexander Bakushkin
Alexander Bakushkin
5,120 Points

Thank you for your answer. In learning path teacher didn't tell about it...I think:))

wow i could not figure this out lol