Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Exercise 11 in Chapter 8 explains how to add large integers using ar

ID: 3662313 • Letter: P

Question

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

#include<stdio.h>
int main()
{
int i, j, rows, columns, a[10][10], b[10][10];
int Addition[10][10], Subtraction[10][10], Multiplication[10][10], Module[10][10];
float Division[10][10];
  
printf(" Please Enter Number of rows and columns ");
scanf("%d %d", &i, &j);

printf(" Please Enter the First Array Elements ");
for(rows = 0; rows < i; rows++)
{
for(columns = 0;columns < j;columns++)
{
scanf("%d", &a[rows][columns]);
}
}

printf(" Please Enter the Second Array Elements ");
for(rows = 0; rows < i; rows++)
{
for(columns = 0;columns < j;columns++)
{
scanf("%d", &b[rows][columns]);
}

}
  
for(rows = 0; rows < i; rows++)
{
for(columns = 0;columns < j;columns++)
{
Addition[rows][columns] = a[rows][columns] + b[rows][columns];
Subtraction[rows][columns] = a[rows][columns] - b[rows][columns];
Multiplication[rows][columns] = a[rows][columns] * b[rows][columns];
Division[rows][columns] = a[rows][columns] / b[rows][columns];
Module[rows][columns] = a[rows][columns] % b[rows][columns];   
}
}

printf(" Add Sub Multi Div Mod");
for(rows = 0; rows < i; rows++)
{
for(columns = 0; columns < j; columns++)
{
printf(" %d ", Addition[rows][columns]);
printf("%d ", Subtraction[rows][columns]);
printf("%d ", Multiplication[rows][columns]);
printf("%.2f ", Division[rows][columns]);
printf("%d ", Module[rows][columns]);
}
}
return 0;
}