Advertisement
Josif_tepe

Untitled

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