Sum of the digits.
Input:
enter a digit 123
Output :
sum of the digits is 6.
Program to print Sum of the digits.
#program to print sum of the digits
digit =int(input("enter a digit "))
sum1=0
while (digit!=0):
remainder = digit % 10
sum1+=remainder
digit//=10
print("sum of the digits is ",sum1)
Output:
enter a digit 123
sum of the digits is 6.
Comments
Post a Comment
Type Your Comments !
Please do not enter any spam link in the comment box.