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

Help with the functions challenge!

I tried almost everything, it keeps saying that { is unqualified or something like that, here is my code...

float addTwo (float a, float b);

{ float a = 11.5; float b = 15.5;

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

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

Please help!

2 Answers

Samiruddin Syed
Samiruddin Syed
3,136 Points

When you are adding 2 Float variables, then you have to store the sum of those 2 variables in a "float" variable as well. You cannot store the sum of 2 float variables into an int variable. Hope that helps.

Thank you for replying but now there is a different issue...

expected unqualified-id { ^ 2 errors generated.

that is the problem after I fixed the "int" to "float"

Thank you for replying but now there is a different issue...