Advertisement
Josif_tepe

Untitled

Aug 20th, 2023
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(int argc, const char * argv[]) {
  4.  
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int zbir = 0;
  9.     while(n > 0) {
  10.         int cifra = n % 10;
  11.         zbir += cifra;
  12.         n /= 10;
  13.     }
  14.    
  15.     printf("%d", zbir);
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement