Suppose you are given a positive integer. You can add individual digits of this number
to get another integer. Now apply the same procedure to the new integer. If we repeat
this procedure, eventually we will end up with a single digit. Here is an example:
7391928 = 7 + 3 + 9 + 1 + 9 + 2 + 8 = 39
39 = 3 + 9 = 12
12 = 1 + 2 = 3.
Write a program that reads a positive integer from the user and displays the single digit
as obtained by the above procedure. For the example, the output should be 3.
Your program should detect negative input as an error and terminate after displaying an
appropriate error message.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here