Lucian_Adrian

Untitled

Oct 12th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n, sum = 0;
  6. cin >> n;
  7. while(n > 0){
  8. sum += n % 10;
  9. n/=10;
  10. }
  11. cout << sum;
  12. return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment