Răspuns:
#include <iostream>
using namespace std;
int iterativ(int n){
int s = 0;
while(n){
if(n%2 == 1)
s += n%10;
n /= 10;
}
return s;
}
int recursiv(int n){
if(n == 0)
return 0;
if(n%2 == 1)
return n%10 + recursiv(n/10);
return recursiv(n/10);
}
int main()
{
int n;
cout << "n = "; cin >> n;
cout << iterativ(n) << ' ' << recursiv(n);
return 0;
}