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

with the following template #include <iostream>//cin,cout #include <iomanip> //s

ID: 3729864 • Letter: W

Question

with the following template

#include <iostream>//cin,cout
#include <iomanip> //setw(10)
using namespace std;

//User Libraries Here

//Global Constants Only, No Global Variables
//Allowed like PI, e, Gravity, conversions, array dimensions necessary
const int COLMAX=80; //Max Columns much larger than needed.

//Function Prototypes Here
void read(int [][COLMAX],int &,int &);//Prompt for size then table
void sum(const int [][COLMAX],int,int,int[][COLMAX]);//Sum rows,col,grand total
void print(const int [][COLMAX],int,int,int);//Either table can be printed

//Program Execution Begins Here
int main(int argc, char** argv) {
//Declare all Variables Here
const int ROW=80; //Max Rows much larger than needed
int array[ROW][COLMAX]={}; //Declare original array
int augAry[ROW][COLMAX]={}; //Actual augmented table row+1, col+1
int row,col;   
  
//Input the original table
read(array,row,col);
  
//Augment the original table by the sums
sum(array,row,col,augAry);
  
//Output the original array
cout<<endl<<"The Original Array"<<endl;
print(array,row,col,10);//setw(10)
  
//Output the augmented array
cout<<endl<<"The Augmented Array"<<endl;
print(augAry,row+1,col+1,10);//setw(10)
  
//Exit
return 0;
}

Task-> Implement the functions specified. 1) Input the rows and column of a table, then input the table. 2) Create a new table augmented by 1 row and 1 column The augmented table has the row sums in the new column and the column sums in the new row. The grand sum is in the lower corner of the table. 3) See the sample test case for the input prompts and the table output format.

Explanation / Answer

#include <iostream>//cin,cout
#include <iomanip> //setw(10)
using namespace std;

//User Libraries Here

//Global Constants Only, No Global Variables
//Allowed like PI, e, Gravity, conversions, array dimensions necessary
const int COLMAX=80; //Max Columns much larger than needed.

//Function Prototypes Here
void read(int [][COLMAX],int *,int *);//Prompt for size then table
void sum(const int [][COLMAX],int,int,int[][COLMAX]);//Sum rows,col,grand total
void print(const int [][COLMAX],int,int,int);//Either table can be printed

//Program Execution Begins Here
int main(int argc, char** argv) {
//Declare all Variables Here
const int ROW=80; //Max Rows much larger than needed
int array[ROW][COLMAX]={}; //Declare original array
int augAry[ROW][COLMAX]={}; //Actual augmented table row+1, col+1
int row,col;

//Input the original table
read(array, &row, &col);

//Augment the original table by the sums
sum(array,row,col,augAry);

//Output the original array
cout<<endl<<"The Original Array"<<endl;
print(array,row,col,10);//setw(10)

//Output the augmented array
cout<<endl<<"The Augmented Array"<<endl;
print(augAry,row+1,col+1,10);//setw(10)

//Exit
return 0;
}

void read(int arr[][COLMAX], int *row, int *col){
cout << "Enter row and columns value: ";
cin >> *row >> *col;

cout << "Enter array value: ";
for(int i = 0; i < *row; i++){
for(int j = 0; j < *col; j++){
cin >> arr[i][j];
}
}
}

void sum(const int arr1[][COLMAX],int row,int col,int arr2[][COLMAX]){
for(int j = 0; j < col; j++){
arr2[row][j] = 0;
}
for(int i = 0; i < row; i++){
arr2[i][col] = 0;
for(int j = 0; j < col; j++){
arr2[i][j] = arr1[i][j];
arr2[i][col] +=arr1[i][j];
arr2[row][j] += arr1[i][j];
arr2[row][col] += arr1[i][j];
}
}
}

void print(const int arr[][COLMAX], int row, int col, int width){
for(int i = 0; i < row; i++){
for(int j = 0; j < col; j++){
cout << arr[i][j] << setw(width);
}
cout << " ";
}
}