A task is a set of statements written to perform a specific task. The function can be built-in or user-defined. Built-in functions are declared and defined by the language itself, which we can use for our program. User-defined are the functions that we have to declare and define as per our need and use in a specific scope.
A single function has four parts.
E.g. int max(int, int); // Here the function max has return type integer and contains 2 parameters of type integer.
After function declaration, we have to write a function body that contains the group of statements used to perform the task. In a parameterized function, the function can access the main method data. All the lines of code are enclosed in the curly braces. In C language, the program also starts from main function i.e., main(). Every statement in the function ends with a ‘;’.
|