What is FUNCTION Procedure? with example.

  • A function procedure is a small manageable and functional part of a program that performs the specific task and it returns a single value to the main program or calling module. It is a block of statement.
  • Functions are exactly similar to the sub-procedure except that functions returns value while sub-procedures do not. A function returns only one value that is assigned to its name inside the function itself. 
  • There are two types of functions which is supported by Qbasic. They are:
    1. Library or Built-in function (read)
    2. User defined function 
            FUNCTION Name (parameters)
            END FUNCTION
  • The first line shows the name of the function and the parameters used to calculate its value. 
  • The data type of value of the function should be shown by a type suffix (%, !, or $) in the name. 
  • The statements below the first line give the procedure for calculating the value of the function; they must include a line assigning the calculated value to the function name.
  • The procedure for calculating the value of the function should not contain statements that change the values of the parameters. This is so that variables substituted for the parameters will not be changed when the function is used. 
For Example: (Click)

Share :

More Quotes
Back To Top

facebook main


Powered by Blogger.