Find sum of digits of a number
| 7 | |
| 8 | // Find sum of digits of a number |
| 9 | long int sumofdigits(long int n) |
| 10 | { |
| 11 | int d; |
| 12 | d=n%10; |
| 13 | if(n<10) |
| 14 | return d; |
| 15 | else |
| 16 | return d+sumofdigits(n/10); |
| 17 | } |
| 18 | |
| 19 | // Recursively find sum of digits till the number is single digit |
| 20 | long int sumuptosingledigit(long int n) |
no outgoing calls
no test coverage detected