User defined functions in C++

The function in C++ language is also known as procedure or subroutine in other programming languages. To perform any task, we can create function. A function can be called many times. It provides modularity and code reusability. In other words, Functions are used to provide modularity to a program. Creating an application using function makes it easier to understand, edit, check errors etc. Basically, A function is a group of statements that together perform a task. Every C++ program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division usually is such that each function performs a specific task. A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.


This is a companion discussion topic for the original entry at http://iq.opengenus.org/user-defined-functions-cpp/