1. What are Functions?
Functions or reusable code blocks designed for particular tasks
Functions are executed when they are called or invoked
Functions are fundamental in all programming languages
Functions are defined with the function keyword:
followed by the function name
followed by parentheses ( )
followed by brackets { }
Sample Program using Function:
2. Calling Functions
Functions are executed when they are called or invoked
You call a function by adding parentheses to its name: name()
3. Function Parameters
Parameters allow you to send values to a function
Parameters are listed in parentheses in the function definition
4. Function Return Values
A function can return a value back to the code that called it
The return statement is used to return a value from a function
5. Function Arguments
Function parameters and arguments are distinct concepts
Parameters are the names listed in the function definition
Arguments are the values received by the function
References:

Top comments (0)