Advertisement
Josif_tepe

Untitled

Nov 3rd, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. int main() {
  6.     int broj;
  7.     scanf("%d", &broj);
  8.     int zbir = 0;
  9.     int posledna_cifra;
  10.     while(broj > 0) {
  11.         posledna_cifra = broj % 10;
  12.         zbir += posledna_cifra;
  13.         broj /= 10;
  14.     }
  15.     printf("%d\n", zbir);
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement