A function is a group of statements that exist within a program for the purpose of performing a specific task. We can use functions to divide and conquer a task
Benefits Simpler Code: Code is easier to read and understand. Code Reuse: Functions reduce duplication of code, if a specific operation is performed multiple times, it can be written once and used over and over again. Better Testing: With each task in its own block, its easier to test and develop. Faster Development: If a programmer has to develop multiple programs, and he discovers that certain tasks are common to them, he can write a function or functions to perform those tasks and reuse them. Easier Facilitation of Teamwork: Functions make it easier to do collaboration.
What mistake can we find in the following code?
Scope and Local Variables
Passing Arguments to Functions