➽ Program:-
num
= int(input("Enter a Number: "))
sum
= 0
while(num>0):
digit = num % 10
sum = sum + digit
num = num // 10
print("Sum
of Digits is",sum)
➽ Output:-
Enter a Number: 456789
Sum of Digits is 39
➽ Program:-
num
= int(input("Enter a Number: "))
sum
= 0
while(num>0):
digit = num % 10
sum = sum + digit
num = num // 10
print("Sum
of Digits is",sum)
➽ Output:-
Copyright (c) 2021 | Coding Plaza | All Rights Reserved
0 Comments
Please do not enter any spam link in the comment section.