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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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