The function gets an integer and a digit, and should return true
if the digit appears an even number of times in the integer, or false if not.
For example:
If digit=1 and num=1125
the function should return true.
If digit=1 and num=1234
the function should return false.
bool isEven(int num, int dig)
{
bool even;
if (num < 10)
even = false;
else
{
even = isEven(num/10,dig);
This is what I’ve got so far, and I’m stuck…
This is homework so please don’t write the answer but hint me and help me get to it by myself.
To set up recursion, you need to figure out two things:
I can see from your code that you’ve made some progress on both of these points. However, both are incomplete. For one thing, you are never using the target digit in your code.