“I ran the code below but it is not working”
is not a useful description of your problem.
Why is this so? Can anyone please explain this.
Your problem is clearly described in the compiler error report, which you should include in your post.
error: no matching function for call to ‘NumberOfPennies(int)’
std::cout << NumberOfPennies(4) << std::endl;
^
note: candidate: int NumberOfPennies(int, int)
int NumberOfPennies(int one, int two)
^~~~~~~~~~~~~~~
note: candidate expects 2 arguments, 1 provided
Thus, you tried to invoke the function with 1 argument, when your declaration requires 2.
By adding the default value for the second parameter,
int NumberOfPennies(int one,int two=0) ...
You have provided a value for the second parameter when not provided.
Review default function parameter.
solved Error in a function call [closed]