Answer:
Written in Python:
inputnum = int(input("User Input: "))
outputnum = 0
total = 0
while(inputnum>0):
remainder = inputnum % 10
outputnum = (outputnum * 10) + remainder
inputnum = inputnum//10
total = total + remainder
print("Reverse: "+str(outputnum))
print("Total: "+str(total))
Explanation:
This prompts user for input
inputnum = int(input("User Input: "))
This initializes the reverse number to 0
outputnum = 0
This initializes total to 0; i.e. sum of each digit
total = 0
The following iteration gets the reverse of user input
<em>while(inputnum>0):
</em>
<em> remainder = inputnum % 10
</em>
<em> outputnum = (outputnum * 10) + remainder
</em>
<em> inputnum = inputnum//10
</em>
<em> This adds each digit of user input</em>
<em> total = total + remainder
</em>
This prints the reversed number
print("Reverse: "+str(outputnum))
This prints the sum of each digit
print("Total: "+str(total))