Question: How to write a C++ program. Additive persistence is a property of the sum of the digits of an integer. The sum of the digits

How to write a C++ program. 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 creating a new sum. This process repeats until a single integer digit is reached. Consider the following example:

1. The beginning integer is 1234

2. Sum its digits is 1+2+3+4 = 10

3. The integer is now 10

4. The sum of its digits is 1 + 0 = 1

5. The integer is 1. When the value reaches a single digit, we are finished. This final integer is the additive root

Program Specifications The program should run as follows.

1) Gather input as a redirection from a file input.txt. The program ends under one of the following circumstances a. the next gathered integer is a negative number. b. if all the integers from the file have been processed. 2) If the given integer is a single digit, report its additive persistence as 0 and its additive root as itself on a single line as two space separated numbers 3) For each multidigit, non-negative, integer output on a single line the two space separated numbers: a. the integer's additive persistence b. the integer's additive root

How to write a C++ program. only use those

Numbers and Operations

Number forms

Numeric Operations

Assignment

Booleans and Relational Ops

Booleans and Relational Ops

Control

if

while

counting for

continue, break and nested loops

count and classify characters in a file

switch and ternary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!