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

Jaber Almarri
PLUS
Jaber Almarri
Courses Plus Student 1,547 Points

I wrote the whole function and I wrote it in Xcode too to be sure, still giving me wrong every time, yet in Xcode its ok

Can anyone tell me whats wrong with my function? because in Xcode runs successfully.

functions.c
float addTwo ( float a, float b );

 {       
        float a = 3.2;
        float b = 4.2;

        float result = addTwo ( a, b );

        printf ( " %f  \n " , result );

         return 0;
}

    float addTwo ( float a, float b )


{
        return a + b ;
}

1 Answer

Gabe Nadel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

In your first version of the function, you can remove the semicolon in this line:

float addTwo ( float a, float b );

Also, inside that function, you don't need to re-declare float a and float b, you should just use the variables you declared in the function definition.

So, your final function would look like:

float addTwo ( float a, float b ) { a = 3.2; b = 4.2;

float result = addTwo ( a, b );

printf ( " %f  \n " , result );

return 0;

}