ivana_andreevska

Untitled

May 15th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. Да се напише рекурзивна функција која ќе го пресметува збирот на цифрите на
  2. еден број.
  3. #include <stdio.h>
  4.  
  5. int zbir_cifri(int broj)
  6. {
  7.     if(broj==0)
  8.     {
  9.         return 0;
  10.     }
  11.     else
  12.         return broj%10+zbir_cifri(broj/10);
  13. }
  14.  
  15. int main()
  16. {
  17.     int n;
  18.     scanf("%d",&n);
  19.     printf("Zbirot na cifrite na %d e %d",n,zbir_cifri(n));
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment