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

Tom Evans
Tom Evans
528 Points

float function

I can't work out what is incorrect here. I have left out main function as suggested in the title. I can run this in xCode and it works (with int main () included), but I keep getting an error when checking the task on the Treehouse website.

float addTwo(float a, float b); { float foo = 22.6; float bar = 22.5; printf("Sum of floats is %f\n", addTwo(foo, bar)); return 0; }

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

The error is:

expected unqualified-id { ^ 1 error generated.

functions.c
float addTwo(float a, float b);
{
    float foo = 22.6;
    float bar = 22.5;
    printf("Sum of floats is %f\n", addTwo(foo, bar));
    return 0;
}

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

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Tom,

All you need for this challenge is your second function as that is all the task is asking for.

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

Happy coding!