When declaring a function we can specify a default value for each of the last parameters. This value will be used if the corresponding argument is left blank when calling to the function. To do that, we simply have to use the assignment operator and a value for the arguments in the function declaration. If a value for that parameter is not passed when the function is called, the default value is used, but if a value is specified this default value is ignored and the passed value is used instead.
int multiply(int a,int b=2)
As we can see in the body of the program there are two calls to the function divide. In the first one:
We have only specigied one argument, but the function multiply allows up to two. So the function divide has assumed the second parameter is 2 since that is what we specified to happen if this parameter was not passed. Therefore the result of the function call is 10 (5*2).
In the second call:
There are two parameters, so the default value for b is ignored and b takes the value passed as argument, that is 3, making the result returned equal to 12 (4*3).