Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why I m not getting the output in the picture. Can somebody help to fix my mess. # include #include #include #include using namespace std;

Why I m not getting the output in the picture. Can somebody help to fix my mess.

# include

#include

#include

#include

using namespace std;

class Matrix

{

public:

Matrix();

// default constructor

// Postcondition: all elements are initialized to 0

double& operator()(const int rn, const int cn);

// rn: row subscript; cn: column subscript

// Postcondition: returns the value of data[rn][cn]

void operator()();

// An overloaded function that sets all array elements to zero

// Postcondition: clears or reset all elements of 2D data array

void transpose(int &numRows, int &numCols);

// numRows and numCols: the actual # rows & columns that are to be operated on

// Postcondition: entire rows and columns are interchanged

void fill2dArray(int &numRows, int &numCols);

// Precondition: numRows

// Postcondition: data array filled with numRows x numCols values

void display2dArray(int &numRows, int &numCols);

// Postcondition: displays the contents of numRows x numCols 2D array

private:

static const int ROW_SIZE = 2, COL_SIZE = 2;

double data[ROW_SIZE][COL_SIZE];

};

Matrix::Matrix(){

data[ROW_SIZE][COL_SIZE] = {0}; // intialize a 2d array to all zero

}

double& Matrix::operator()(const int rn, const int cn){

double requestedData = data[rn][cn];

return requestedData; // return the requested data

}

void Matrix::operator()(){

data[ROW_SIZE][COL_SIZE] = {0}; // reset all to zero

}

void Matrix::transpose(int &numRows, int &numCols){

double transMatrix[ROW_SIZE][COL_SIZE] = {0}; // create a temp matrix

for(int i=0;i

for(int j=0;j

transMatrix[j][i]=data[i][j]; // transpose the data

}

}

for(int i=0;i

for(int j=0;j

data[i][j]=transMatrix[i][j]; // set the transaposed matrix to original matrix

}

}

}

void Matrix::fill2dArray(int &numRows, int &numCols){ // get the data one by one from user

for(int i=0;i

for(int j=0;j

cout

cin>>data[i][j];

}

}

}

void Matrix::display2dArray(int &numRows, int &numCols){ // display the entire array

for(int i=0;i

cout

for(int j=0;j

cout

}

}

}

int main ()
{
 int A[10][10], m, n, i, j;
 cout  
 cin >> m >> n;
 cout  
 for (i = 0; i  
 for (j = 0; j  
 cin >> A[i][j];
 cout   ";
 for (i = 0; i  
 { 
 for (j = 0; j  
 cout  
 cout   ";
 }
 cout   ";
 for (i = 0; i  
 {
 for (j = 0; j  
 cout  
 cout   ";
 }
 return 0;
}

image text in transcribed

C: Windows exe You may enter up to 10 rows and 10 columns of numbers How many rows? 3 manuy colunns? 5 Enter 5 values for row #0 1 2 3 4 5 Enter 5 values for row #1 6 7 8 910 Enter 5 values for row #2 11 12 13 14 15 Contents of the 3 5 array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 After transpose: 1 6 11 2 7 12 3 8 13 4 9 14 5 10 15 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago