Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long DigitSum(long n1)
- {
- if(n1 == 0)
- return 0;
- else
- return ((n1 % 10) + DigitSum(n1 / 10));
- }
- int main()
- {
- long n1, sum;
- scanf("%ld", &n1);
- sum = DigitSum(n1);
- printf("%ld",sum);
- return 0;
- }
Add Comment
Please, Sign In to add comment