Advertisement
Josif_tepe

Untitled

Nov 17th, 2023
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.    
  10.     int zbir =0 ;
  11.     for(int x = n; x > 0; x /= 10) {
  12.         int cifra = x % 10;
  13.         zbir += cifra;
  14.     }
  15.     cout << zbir << endl;
  16.    
  17.     return 0;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement