Summary

  1. Functions help in modularizing a program into smaller simple parts.
  2. Functions are classified based upon: (a) who develops the function and (b) the parameter and the return type of the function.
  3. Based upon who developed the function, they are categorized as: (a) user-defined functions and (b) library functions.
  4. Based upon the parameter and the return type of the function, they are categorized as: (a) functions with no input and no output, (b) functions with inputs but no output, (c) functions with inputs and a single output and (d) functions with inputs and multiple outputs.
  5. User-defined functions are defined by the user at the time of writing a program and are also known as programmer-defined functions.
  6. There are three aspects of working with user-defined functions: (a) function declaration, (b) function definition and (c) function call.
  7. Function definition, also known as function implementation means composing a function. Every function definition consists of two parts: (a) header of the function and (b) body of the function.
  8. A function with no input–output does not accept any input and does not return any result.
  9. The execution of a C program always begins with the function main. It need not to be called explicitly.
  10. Functions whose return type is void are known as void functions. void functions do not return any value.
  11. While calling a function, the expressions that appear within the parentheses of a function call are known as actual arguments, and the variables declared in the parameter list in the header of function definition are known as formal parameters.
  12. The return statement is to return the result of computations done in the called function and/or the program control back to the calling function.
  13. There are two forms of return statement: (a) return; and (b) return expression;.
  14. Depending upon whether values or addresses are passed as arguments to a function, the argument passing methods in C language are classified as: (a) pass by value and (b) pass by reference/address.
  15. If arguments are passed by value, the changes made in the values of formal parameters inside the called function are not reflected back to the calling function.
  16. If the arguments are passed by reference/address, the changes made in the values pointed to by the formal parameters in the called function are reflected back to the calling function.
  17. A function can return only one value by using the return statement but it can indirectly return more than one value using the concept of pass by reference/address.
  18. When an array is passed as an argument to a function, it implicitly gets converted to a pointer type.
  19. The arguments can be made default by using an initialization syntax within the parameter list during the function declaration.
  20. The default argument should not be specified in the function definition.
  21. Function calling itself is called recursive function and the process is known as recursion.
  22. Recursive functions may be: (a) direct recursive/indirect recursive and (b) tail recursive/non-tail recursive.
  23. There are three patterns of recursive calls: (a) linear, (b) binary and (c) n-ary.
  24. Like recursion, pointers to functions provide an extremely interesting, efficient and elegant programming technique.
  25. A pointer to a function, commonly known as the function pointer, is a variable that points to the address of a function.
  26. Library functions or pre-defined functions are the functions whose functionality has already been developed by someone and is available to the user for use.
  27. The arguments to the function main are supplied at the command line and thus have a special name known as command line arguments.

Post a Comment

Previous Post Next Post