Functions
A function is a block of code which only runs when it called.Passed data into a function is known as parameters.
Need of Function:
- Function reduces the redudancy of code.
- Function make code modular.
- Function provide abstraction.
Function Creation:
C++ provides some pre_definedd functions,such as main(),which is used to execute code.But we can also create our own functions to perform cirtain actions.
To crate a function ,specify the name of the function, followed by parentheses();.
Function Declaration and Defination:
A C++ function consists of two parts:
- Declaration- The function's name,return type,and parameters.
- Definition- The body of function.

Function calling:
Declared function are not executed immediately.They will executed when they are called.
To call a function,write the function's name followed by two parenthesis () and a semicolon ;.
A function can be called multiple times.
Parameter Passing to Function:
Parameters passed to a function are called actual parameters.
Parameters recieved by function are called formal parameters.
Comments
Post a Comment