FUNCTIONS

Cards (8)

  • Functions are generally used to make programs modular. This means that programs are subdivided into modules or “functions” which allow programs to be read or modified easily. ​
    1. A function must be declared prior to its use except when it is already defined.
  • 2. The parameter list of a function may have parameters of any data type
  • 3. Parameters are optional.
  • 4. The number and data types of parameters should match the number and data types of the arguments passed on to it. 
  • 5. The return statement is used to return a single value from a function. It usually appears at the last line of a function but it may also appear anywhere within a function. ​
  • 6. The return statement is optional. ​
  • 7. If the data type of the value returned of a function is not declared, it is converted to int. 8. If a function does not return a value, its return type will be void.