here is the project: An array can be used to store large integers ine digit at a
ID: 3619286 • Letter: H
Question
here is the project: An array can be used to store large integers ine digit at atime. For example, the integer 1234 could be stored in the array aby 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 digitsbackward, that is, place 4 in a[0], 3 in a[1], 2 in a[2], 1 ina[3]. In this exercise you will write a program that reads in twopositive integers that are 20 or fewer digits in length and thenooutputs the sum of the two numbers. Your program will read thedigits as values of type char so that the number 1234 is read asthe four characters '1', '2', '3', '4'. After they are read intothe program, the characters are changed to values of type int. Thedigits will be read into a partially filled array, and you mightfind it useful to reverse the order of the elements in the arrayagter the array is filled with data from the keyboard. (Whether ornot you reverse the order of the elements in the array is up toyou. It can be done either way, and each way has its advantages anddisadvantages.) Your program will perform the additition by implementing theusual paper and pencil addition. The result of the addition isstored in an array of size 20, and the result is then written tothe screen. If the result of the addition is an integer with morethan the maximum number of digits (that is more than 20 digits),then your program should issue a message saying that it hasencountered "integer overflow". You should be able to change themaximum length of the integers by changing only one globallydefined constant. Include a loop that allows the user to continueto do more additions until he says it should end. here is the project: An array can be used to store large integers ine digit at atime. For example, the integer 1234 could be stored in the array aby 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 digitsbackward, that is, place 4 in a[0], 3 in a[1], 2 in a[2], 1 ina[3]. In this exercise you will write a program that reads in twopositive integers that are 20 or fewer digits in length and thenooutputs the sum of the two numbers. Your program will read thedigits as values of type char so that the number 1234 is read asthe four characters '1', '2', '3', '4'. After they are read intothe program, the characters are changed to values of type int. Thedigits will be read into a partially filled array, and you mightfind it useful to reverse the order of the elements in the arrayagter the array is filled with data from the keyboard. (Whether ornot you reverse the order of the elements in the array is up toyou. It can be done either way, and each way has its advantages anddisadvantages.) Your program will perform the additition by implementing theusual paper and pencil addition. The result of the addition isstored in an array of size 20, and the result is then written tothe screen. If the result of the addition is an integer with morethan the maximum number of digits (that is more than 20 digits),then your program should issue a message saying that it hasencountered "integer overflow". You should be able to change themaximum length of the integers by changing only one globallydefined constant. Include a loop that allows the user to continueto do more additions until he says it should end.Explanation / Answer
please rate - thanks #include using namespace std; #define MAX 20 void unpack(char[],int[],int&); void add(int[],int[],int[],int,int,int&); void print(int[],int[],int[],int,int,int); void printin(int[],int); int main() {char input[MAX]; int n1[MAX],n2[MAX],n3[MAX],l1,l2,l3; char more='Y'; while(toupper(more)=='Y') {coutinput; unpack(input,n1,l1); coutinput; unpack(input,n2,l2); add(n1,n2,n3,l1,l2,l3); print(n1,n2,n3,l1,l2,l3); coutmore; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.