Răspuns:
#include <iostream>
int sum ;
int suma( int n ) {
while (n!=0) {
sum=sum+n%10; // adaugi produsul ( prod=1 )
n/=10;
}
return sum;
}
int main() {
int n ;
std::cout << "Enter un numar : " ;
std::cin >> n;
std::cout << "Suma cifrelor numarului : " <<suma(n) ;
return 0;
}