The sum of the figures of the number
Write a program that receives a number from the user and prints the sum of its figures in the output
Write a program that receives a number from the user and prints the sum of its figures in the output
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
const num = prompt("Enter number"); let sum = 0; for (let number of num) { sum += parseInt(number); } console.log(sum);
total=0 a=int(input('num:')) for i in str(a): total += int(i) print(total)
It's wrong
def sum_of_numbers(i): while 1: a=int(input('num:')) if a==0: break i+=a print(i) d=int(input('num:')) print(sum_of_numbers(d))
l = []
while True:
a = float(input("Enter a number: "))
l.append(a)
if a == 0:
b = sum(l)
print("jame: ", b)
break
num=int(input("num: ")) x=0 while num>0: digit=num%10 x+=digit num=num//10 print(f"total: {x}")
# sum of digits Num = int(input("Give me a number: ")) sum = 0 while Num != 0 : Num1 = int(Num % 10) Num = int(Num / 10 ) sum = sum + Num1 print(f"The sum of digits is: {sum}")
a=int(input("num:")) b=int(input("num:")) print(a+b)
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.