Home >>C++ Tutorial >C++ Functions
In order to perform or execute any task, the functions are used in the C++ programming. Hence, it is also known as the procedure in various programming languages. The functions have many benefits like it can be called various times provide the reusability of the written code.
Here are the advantages that the programmer gets by the functions in C++
There are generally two types of the functions in the C++ language:
Here is the syntax that is used to declare any function in the C++ programming:
return_type function_name(data_type parameter...) { //code that is to be executed }
Here is an example of the simple C++ function that will help you understand the topic better:
#include <iostream> using namespace std; void demo() { int i=10; cout<<"i=" << i<<"\n"; } int main() { demo(); demo(); demo(); }