void sum_digits(int & n, int & sum)
{
if ( n == 0 ) return;
sum += n % 10;
n /= 10;
sum_digits(n, sum);
}
#include <iostream>
using namespace std;
int main()
{
int n, sum=0;
cout << "enter a non-negative number" << endl;
cin >> n;
if ( n < 0 ) return -1; sum_digits(n,sum);
cout << "sum is " << sum << endl;
}