Explain Functions in c++


Functions in c++: a function is a set of executable statements having well defined specific task that can be processed independently. The function can be designed, developed, and implemented independently by different programmers.functions are independent because variable names and labels defined within its body are local to it.


The following are the advantages of functions:

  1. Modular programming.
  2. Reduction in the amount of work and development time.
  3. Program and function debugging is easier.
  4. Division of work is simple and easy due to use of divide and conquer principle.
  5. Reduction of size in the program is due to code re usability.
  6. Functions can be accessed repeatedly without redevelopment; which in turn promotes reuse of code.
  7. Library of functions can be implemented by combining well-designed, tested, and proved functions.

When we call the function , control is transferred to the first statement in the function body. The other statements in the function body are then executed and the control return to the calling program.

Function components :
every function has the following components associated with it: 



0 Comments