Josif_tepe

Untitled

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