I have watched several YouTube videos on user defined functions however I still don't have a solid understanding of it. When would you create a user defined function? What's their purpose? How does the void function differ from the int function? When do you need to call a function and when do you not? Please explain thoroughly, as I am a 13 year old coding n00b. Thanks in advance.
A function is a group of statements that're executed when the function is invoked. A function consists of 4 parts:
Return Type-Specifier
This indicates the type of data the function returns when it's finished (via the return statement). A function with a void type-specifier indicates that the function doesn't return any data.
Identifier
This is the name of the function. When you invoke a function, you identify the function you want to call by stating its name.
Parameter List
This is where you define the parameters of the function. Parameters are a group of variables or objects that contain the arguments given when you invoke the function. If a parameter list is empty, or explicitly defined as empty with void, it indicates that the function doesn't require arguments.
The Body
This is where the statements of the function reside. When main( ) invokes your function, it jumps to the top of the functions body. Each statement is executed one after another until either return is encountered, or, until all statements have been executed (void function).
YouTube videos are a terrible resource to learn programming from.. pick up a good book,
http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list