...

/

Function Parameters and Return Values

Function Parameters and Return Values

Learn to use parameters and return values with user-defined functions in C++.

Function with parameters

The parameters are the input values for the function enclosed in (), provided in the function call as arguments. Multiple parameters are separated by , and each parameter must have a data type. The following function receives two int parameters and displays their sum.

void showSum(int a, int b)
{
 cout << a + b << endl;
}

The following is the function call sending 5 and 10 as arguments:

showSum(5,10);
Access this course and 40+ top-rated courses and projects.