Sum of Individual Digits of a Number in Python
Hello Everyone, In this post i am gonna discuss about how to write python program to find the sum of individual digits of a number.. Ok,Lets move on to the Program. Program: n=int(input("enter number")) sum=0 while n!=0: sum=sum+n%10 n=n//10 print("sum is",sum) It is a very simple program where we calculate the sum of each digit of the given number.here we use while loop for repeating the operation. see the image for the output... Here is same code in Java, http://vitaminj.kittu.xyz/2017/12/find-sum-of-digits-of-given-integer.html Stay tuned for more interesting topics.. Thanks