I am new to C++ and i wrote a recursive function to display the number of even digits in an integer. I dont understand why it is not working. Any help would be much appreciated. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int numEven (int x)
if (x % 2 == 0) return numEven(x/10) + 1;
return numEven(x/10); }
int main () {
int x;
cout << "Input a number to find the number of even digits \n";
cin >> x;
if (x<=0) return 0;
numEven(x);
return 0;
}