Advertisement
LegoDrifter

suma na cifri rekurzija

Feb 1st, 2020
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.21 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int sumacifri(int n)
  4. {
  5.     if(n==0)
  6.         return n;
  7.     else
  8.         return n%10+sumacifri(n/10);
  9. }
  10. int main()
  11. {
  12.     int n;
  13.     scanf("%d",&n);
  14.     printf("%d",sumacifri(n));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement