C++ Function

Function is a set of instructions, that  performs a specific task. Function can be processed independently and called by another function. function performs the task and returns control to the calling function or program. function may perform such as initializing a set of variables or it may accept values by arguments.

Advantage of using the functions is that it is possible to reduce the size of a program by calling and using them at different places in the program.

functions in C++

Advantages of using functions in a  program :-

  • The complexity of the entire program can be divided into simple subtask and then function subprograms can be written for each subtask subprogram are easier to write, understand and debug.
  • A function can be shared by  other programs.
  • A function can call itself again, it is called a recursive function.
  • Size of a program can be reduced using function.

 

Main Function :-

main() is the entry point for the complier in a program for the execution
of a program.

Definition of main() :-

main() { ………………. /* body of main function */ ……………….. }

 

Main function return some value, when used int data type. Example :- int main() { ………………. /* body of main function */ ……………….. return 0; }




Follow Us

Contact Us

tutorialworldin@yahoo.com

Back to Top