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);
Get hands-on with 1400+ tech skills courses.