C++ Functions

C++ Functions


C++ Functions :

  • Functions are building blocks of programs.
  • A set of statements that explains what is function does is called function.
  • A can be written at before main() and after main() in a separate file.
  • The statement activates a function is known as function call.
  • All C++ programs must contains functions main().
  • The execution of the program starts from the function main().

 

The Syntax of C++ function is as follows;

functionType functionName(){

        // Statements

}

Example1: In this shows that thisIsFunction() is used to print a text, when calling function.

 

Output :

 

Example2: A function can be called more times:

 

Output :