The summation of digits is performed creating a new sum

Assignment Help Computer Engineering
Reference no: EM132194595

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 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

input.txt

3

8 9 19 199 1234567890 -5 127
output.txt should be like this

0 3 0 8 0 9 2 1 3 1 2 9
which is 1st. the integer's additive persistence 2nd. the integer's additive root

Reference no: EM132194595

Questions Cloud

A program that breaks a given number of cents : Write a C++ program that breaks a given number of cents (whole number) down into units of currency (USD).
Write a c program that calculates the power of a number : Write a C program that calculates the power of a number. Put calculations in a separate function, let's say power().
Single-precision real format permit an exponent : Why doesn't the single-precision real format permit an exponent of 128?
Web-based training : What are some technologies included into a Web-based Training and what are some pros and cons of it.
The summation of digits is performed creating a new sum : The sum of the digits is found, and then the summation of digits is performed creating a new sum.
Which web session vulnerability is directly associated : Which web session vulnerability is directly associated with sessions that remain valid for periods longer than they are needed?
What is the height of the cliff : An arrow is shot from a height of 1.3 m toward a cliff of height H. It is shot with a velocity of 31 m/s at an angle of 60° above the horizontal.
Design a class called heading that has data members to hold : Design a class called Heading that has data members to hold the company name and the report name.
Write the problem solving methodology of top down approach : Write the pseudocode for the following problem ( importantMsg ). Write the problem solving methodology of top down approach , iterative refinement .

Reviews

Write a Review

Computer Engineering Questions & Answers

  Determine the z-transforms and sketch the roc

Design a digital Chebyshev-II filter and determine the coefficients of the impulse response h(n) of the FIR filter and Determine the Z-transforms and sketch the ROC

  What are two different forms of spread spectrum technology

What are the two different forms of spread spectrum technology? What is a computer virus, and what are the major types of computer viruses?

  Give an example of a nonporous item and what method you

1.give an example of a nonporous item and what method you would use to process it. where might you expect to find

  Discuss current issue in information systems associated

Search for an article on a current issue in Information Systems associated with big data and analytics

  Describe a process of making it more widely

Conflict-management techniques allow managers to control conflict levels (not only decrease but also increase them). choose a problem that disturbs you and is not solved.

  Write an assembly program to multiply two bit binary number

Write an assembly program to multiply two 31 bit binary numbers (A & B), using the "shift and add" algorithm, which historically is used in computers.

  Display total cost of their selection including sales tax

Create Web site that allows users to enter their first and last names phone number and e-mail. Display the total cost of their selection including 7% sales tax.

  How to produce a function mult-stream

How to produce a function mult-stream.

  List four different types of network segments

The systems development lifecycle (SDLC) provides a standardized process for all phases of any system development.

  Define how to compare the word in ax to the one in cx

define how to Compare the word in AX to the one in CX

  What is meant by an open system

What is meant by an open system? Why are some systems not open? What is difference between a connection-oriented and connectionless communication protocol?

  You have been tasked with the project of organizing a

you have been tasked with the project of organizing a company offsite 2-day training session in which people are

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd