C++ Programming 4. Programming Exercise 11 in Chapter 8 explains how to add larg
ID: 655226 • Letter: C
Question
C++ Programming
4. Programming Exercise 11 in Chapter 8 explains how to add large integers using arrays. However, in that exercise, the program could add only integers of, at most, 20 digits. This chapter explains how to work with dynamic integers. Design a class named largeIntegers such that an object of this class can store an integer of any number of digits. Add operations to add, subtract, multiply, and compare integers stored in two objects. Also add constructors to properly initialize objects and functions to set, retrieve, and print the values of objects.
Explanation / Answer
Pointers, Classes, Virtual Functions, and Abstract Classesstore 35 into the second memory location. Thus, by using the increment and decrementoperations, you can access the components of the array. Of course, after performing a fewincrement operations, it is possible to lose track of the first array component. C++ allowsus to use array notation to access these memory locations. For example, the statements:p[0] = 25;p[1] = 35;store 25 and 35 into the first and second array components, respectively. That is, p[0]refers to the first array component, p[1] refers to the second array component, and so on.In general, p[i] refers to the (i + 1)th array component. After the preceding statementsexecute, p still points to the first array component. Moreover, the following for loopinitializes each array component to 0:for (j = 0; j < 10; j++) p[j] = 0;in which j is an int variable.When the array notation is used to process the array pointed to by p, p stays fixed atthe first memory location. Moreover, p is a dynamic array created during programexecution. The statement: int list[5]; declares list to be an array of five components. Recall from Chapter 9 that list itself is a variable, and the value stored in list is the base address of the array
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.