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

UNI SUN
UNI SUN
376 Points

Tried this numerous ways. Seems to be a syntax issue...ironically Treehouse has a typo in the error message...parameter

float a=1.1; float b=1.2; float addtwo(float a, float b){

return a+b;};

This should work, unless the return can't add...so I also tried making a float named c...made it equal to a+b...and then returned c....yet that didn't get through either...

2 Answers

Hi Uni,

Your only problem is that you didn't capitalize the 't' in addtwo Your code will pass at that point.

It's not necessary to define the variables.

Your semicolon at the end of the function block will count as an empty statement and isn't necessary to put in.

It's as if you wrote it like this:

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

You have your function definition and then an empty statement afterwards which doesn't do anything.

Chris Shaw
Chris Shaw
26,676 Points

Hi Uni,

The challenge is only asking for you to write the function so you don't need the floats declared before it, also you have a semi-colon after your closing brace which will cause a syntax error.

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