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