Calling a Function

When creating a C++ function, you define what the function must do. To use a function, you must call or call the function. When a program calls is a function, program control is transferred to the called function. The called function performs a defined task and returns program control to the main program when the return statement is executed or when its function closing closing parenthesis is reached. To call a function, just pass the required parameters and the function name, and if the function returns a value, then you can store the returned value. For example -

program.

using namespace std;
// function declaration//
int head(int num1, int num2);
int main() {
// local variable declaration://
int a = 100;
int b = 200;
int ret;
// calling a function to get max value.//
ret = head(a, b);
cout << "head value is : " << ret << endl;
return 0;
}
I keep the max() function and main() function and compile the source code. When running the final executable, it produces the following results −

result


Max value is : 200

Difference Between Function Declaration and Function Definition in C plus plus Programming

The principle distinction between Function Declaration and Function Definition in C++ Programming is that Function statement shows what the capacity is and Function Definition demonstrates what the capacity does. C++ is an undeniable level universally useful programming language created by Dennis Richie. It is the establishment programming language of numerous different dialects like C++, Python, Java, PHP, and so forth A capacity is a significant idea in C++ programming. It is a bunch of proclamations that plays out a specific undertaking. Rather than composing every one of the assertions inside the principle program, the software engineer can make capacities and call them inside the primary program. It makes the program more coherent. After the execution of the capacity, the control passes back to the primary program. A capacity has a presentation and definition. The presentation is a model whhile the definition contains the real execution.

Functionality

Practically, the contrast between work presentation and capacity definition is that the capacity statement assists with demonstrating the compiler about the capacity and how to call that capacity, and so on while Function definition assists with composing what the capacity ought to perform. It is the real execution of the capacity.

example 2 "program"

output

example 3

output