The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Please see the attached doc. It is C programming. And write a code for what the question asks.Â
Â
Â
Question 6 – 20 pts
The aim of this assignment is to practice the use of while loops and conditionals statements.
You are going to write a program that prompts the user for an integer and then determines the
additive persistence with corresponding additive root, and the multiplicative persistence
with corresponding multiplicative root of that integer. The program has to prompt the user
for more inputs until the user quits. Additive persistence is a property of the sum of the digits of an integer. The sum of the digits
is found, and then the summation of digits is performed on the sum, repeating until a single
integer digit is reached. The number of such cycles is that integer’s additive persistence.
Consider the following example:
a) The beginning integer is 1234
b) Sum its digits is 1+2+3+4 = 10
c) The integer is now 10
d) The sum of its digits is 1 + 0 = 1
e) The integer is 1. When the value reaches a single digit, we are finished. This final
integer is the additive root The number of cycles is the additive persistence. The integer 1234 has an additive persistence
of 2 (first sum was 10, then the second sum was 1). The final digit reached is called the
integer’s additive digital root. The additive digital root of 1234 is 1. The multiplicative persistence and resulting multiplicative root are determined the same way,
only multiplying the digits of an integer instead of adding. For example: 1. The beginning integer is 1234
2. The product of 1*2*3*4 = 24
3. The integer is now 24
4. The product of 2*4 = 8
5. The integer is now 8. When the value reaches a single digit, we are finished. This final integer is the multiplicative root. As before, the number of cycles is the multiplicative persistence. For 1234, the multiplicative
persistence is 2, and its multiplicative root is 8. Program Specifications
The program should run as follows.
1) Ask the user for an integer.
2) If the integer is less than 0, that is a signal to quit the program.
3) Otherwise, find the additive/multiplicative persistence and additive/multiplicative root
of the given integer and report the results to the user.
4) Continue by prompting the user until they quit.
-----------