Sunday, 21 June 2015

Introduction to Functions in Programming

Functions is a module which takes input and gives some output.

It can be

  • inbuilt
  • user defined
What happens in black-box is not required and is hidden. These hidden details are said to be abstract. 

Break large program into smaller problems and compose them together into one unit later on. Using of standard library functions is good programming practice to save time.

Functions are used to
  • Hiding the details
  • incorporate changes
  • Facilitates modular programming
  • Reusable
We have caller and callee. Caller can give any number of calls to callee. This is called re-usability.

Function cannot be written completely in other function. Main() is the very first function which is used. The control flow can move from one function to another as called by caller and return back. 

Prototype tells the blackbox description of function i.e. inputs, number of inputs, types of inputs, return types etc. 

Calling programs pass actual parameters. Information is accessed by called functions using formal parameters. 

No comments:

Post a Comment