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

Shaun Kelly
Shaun Kelly
5,648 Points

funkymath function and main function

Trying to understand the difference between main function, funkymath function and functions in general. Are the comments right about the following lines of code ?

// declaration of the function which is called funkymath and holds two parameters which are int's in this situation ?
int funkyMath(int a, int b);


//every C programme must contain a main function which is the starting point in execution? 
int main()

{


    int foo = 20;
    int bar = 30;
    printf("funky math %d\n", funkyMath(foo, bar));


    return 0;
}


// implementation of the funkymath function
int funkyMath(int a, int b){


//returning the two int values and adding one ? 
    return a + b + 1;
}