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

AddTwo function

Hi everybody, I tryed to accomplish my simple function called AddTwo. (Result i did receive for my implementation is:

expected unqualified-id { ^ 2 errors generated.

Thank You!!! :)

This is my code:

int addTwo(float a, float b);

{ float a = 1.5; float b = 5.5;

int result = addTwo(a, b);
printf("addTwo %d\n", result);
return 0;

}

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

4 Answers

Thomas Nilsen
Thomas Nilsen
14,957 Points

I didn't look at your code carefully enough. It had some mistakes. Here is what it's supposed to look like :)

float addTwo(float a, float b){
    return a + b;
}
Thomas Nilsen
Thomas Nilsen
14,957 Points

Try

float addTwo

instead of

int addTwo

Hi Thomas, first of all. Thank You for your help. But it seems that I am still where I was.. even when I tried :) to replace int by float.. But even if we will not solve it. I feel ok. And I do continue to learn.. As Xcode did accept my answer and did execute the code.. :).. take care. Radek

Thank You Sir. R.