Given a number, find sum of its digits.
Input : n = 687 Output : 21 Input : n = 12 Output : 3
How to compute in single line?
Please refer complete article on Program for Sum the digits of a given number for more details!
My Personal Notes arrow_drop_up
- C Program to Check if all digits of a number divide it
- C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- C Program for Difference between sums of odd and even digits
- C/C++ Program to Find the Number Occurring Odd Number of Times
- C Program for factorial of a number
- C/C++ Program for nth Catalan Number
- C/C++ Program for n-th Fibonacci number
- C Program to Check Whether a Number is Prime or not
- Lex program to check whether input number is odd or even
- C++ Program to check Prime Number
- C Program to check Armstrong Number
- C/C++ Program for Triangular Matchstick Number
- C Program for Find sum of odd factors of a number
- C Program for Minimum number of jumps to reach end
- C/C++ Program for nth multiple of a number in Fibonacci Series