A function is a block of code which performs some specific task and returns back to the caller. It has a unique name.
They are helpful when need to perform the same task with different-different values or require to use the same block of code in other places within the program.
If any changes require in the future then only need to update the function code and it will automatically make change where the function it been called.
The main aim of a function is –
- To make the program more readable, and organized and,
- Reduce repeated code.