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.