fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n, sumaDig=0;
  8. cin >> n;
  9. while(n>0){
  10. sumaDig = sumaDig + (n%10);
  11. n = n / 10;
  12. }
  13. cout << sumaDig;
  14. return 0;
  15.  
  16. }
Success #stdin #stdout 0.01s 5280KB
stdin
123
stdout
6