Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. For example, the program should: output the individual digits of 3456 as 3 4 5 6 and the sum as18,

Respuesta :

The program is an illustration of loops; Loops are used for repetition

The actual program

The program written in Python, where comments are used to explain each line is as follows:

#This gets input for the number

n = int(input())

#This initializes the sum to 0

sumTotal = 0

#This iterates through the digits

for x in str(n):

   #This adds each digit

   sumTotal+=int(x)

   #This prints each digit

   print(x,end =' ')

#This prints a new line

print()

#This prints the total

print(sumTotal)

Read more about loops at:

https://brainly.com/question/24833629

#SPJ1

ACCESS MORE