How to Initialize Input Parameters in the Procedures

A procedure, function, or subroutine are all segments of larger programs that generally perform a highly specialized task. An example procedure is one that sorts lists. A list is sent over to the procedure, and the procedure performs the steps necessary to sort the list, and a sorted list is returned. The input list is known as an input parameter. Sometimes, you need to initialize input parameters. This way, a procedure can be called and a default value can fill in for any input parameters left out by the user.

Things You'll Need

  • Computer with text editor
Show More

Instructions

    • 1

      Load the source code file for the program source code you want to edit. Click on the source code file to automatically open the default text editor for your system.

    • 2

      Locate a subroutine, function, or procedure. Functions can be identified by their signatures. A function has a return statement, a name, and a set of inputs. In the languages based on C (C, C#, C++, Java, ObjectiveC), a function signature may look something like this:

      int functionName(int input)

      {}

    • 3

      Initialize the input parameters by using the assignment operator. You need to place the assignment operator inside the argument list of the function signature, and assign a default value to the input argument. For example, to set "input" from "functionName" to 0 by default, you could write the following:

      int functionName(int input=0)

      {}

Related Searches:

References

Comments

Related Ads

Featured