Advertisement
vsonia2004

Suma cifrelor unui numar

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