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

  Why we use void main in c programming

Why we use void main in C programming?

  Question construct the huffman code for the java keyword

question construct the huffman code for the java keyword and weights given in the following

  Describe some of the emerging trends in information

discuss some of the emerging trends in information technology e.g. computer hardware software data analysis. what

  Explain the risks and benefits of virtualization

How would you recommend that your IT department prepare for disaster.

  Devise method for implementing global time-ordered broadcast

Devise a simple method for implementing global time-ordered atomic broadcast using only unicasting.

  Provide the measures of tendency and dispersion

Write an essay of 2-3 pages that contains following: Provide the measures of tendency and dispersion for each of the 5 different sections of data you selected.

  Write a program that serves as a mouse odometer

Write a program that serves as a mouse odometer, continually displaying how far, in pixels, the mouse has moved (while it is over the program window).

  Implementing the python atm program

Write down a simple Python ATM program. Ask user to enter their account number, and then print their beginning balance. Then ask them if they wish to make a deposit or a withdrawal.

  Define business strategic objectives

Business Strategic Objectives - From the information in the Case Study, list the three strategic objectives

  Find out the capability of all computers

find out the capability of ALL computers

  What are the limiting factors for grown mesh networks

Given a computer with a disk capacity of 16 GB and a word size of 32 bits, how many wordssize of 32 bits, how many words can be stored on the disk? Show your calculations.

  Declare a numeric type made up of the single-digit numbers

Declare a numeric type made up of the single-digit numbers. Declare a type called Degrees with eight digits of precision and a range required for a circle.

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