Change the maximum length of the integers

Assignment Help Basic Computer Science
Reference no: EM131609062

Question: An array can be used to store large integers one digit at a time. For example, the integer 1234 could be stored in the array a by setting a[0] to 1 , a[1] to 2 , a[2] to 3 , and a[3] to 4 . However, for this exercise you might find it more useful to store the digits backward; that is, place 4 in a[0] , 3 in a[1] , 2 in a[2] , and 1 in a[3] . In this exercise, write a program that reads in 2 positive integers that are 20 or fewer digits in length and then outputs the sum of the 2 numbers. Your program will read the digits as values of type char so that the number 1234 is read as the four characters 1; 2; 3; 4;. After they are read into the program, the characters are changed to values of type int. The digits should be read into a partially filled array; you might find it useful to reverse the order of the elements in the array after the array is filled with data from the keyboard. (Whether or not you reverse the order of the elements in the array is up to you. It can be done either way, and each way has its advantages and disadvantages.) Your program should perform the addition by implementing the usual paper-and-pencil addition algorithm. The result of the addition should be stored in an array of size 20, and the result should then be written to the screen. If the result of the addition is an integer with more than the maximum number of digits (that is, more than 20 digits), then your program should issue a message saying that it has encountered "integer overflow." You should be able to change the maximum length of the integers by changing only one named constant. Include a loop that allows the user to continue to do more additions until the user says the program should end.

Reference no: EM131609062

Questions Cloud

Promotion to earn more awareness : Baldwin's Elite product manager should spend in promotion to earn more awareness than Andrews' Able product?
What are the two sources of economies of scale : Mongolia and Malaysia have very different trading pattern. What are two source of economies of scale? How do the economies of scale lead to intraindustry trade?
Enhance the definition of the class partially filled array : Enhance the definition of the class Partially Filled Array in the following way: When the user attempts to add one additional element and there is no room.
What is a time in your personal or professional life : What is a time in your personal or professional life where a goal affected the negotiation process? What was the goal, and how did it influence the negotiation?
Change the maximum length of the integers : An array can be used to store large integers one digit at a time. For example, the integer 1234 could be stored in the array a by setting a[0] to 1.
Discuss the cycle of violence : One of the prominent aspects and/or debates in criminal justice is the topic of the cycle of violence and how this contributes to criminality.
Understand the importance of credit : This exercise will better help you understand the importance of credit. Take a 30-yr mortgage,
Calculate the total variance for an increase : Calculate the total variance for an increase of 0.20 in its beta. Calculate the total variance for an increase of 6.23% in its residual standard deviation.
Define native american and mennonite approaches : describing and defining the similarities and differences between Native American and Mennonite approaches to restorative justice

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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