The program needs to take two matrices provided by the user and either add or mu
ID: 3652954 • Letter: T
Question
The program needs to take two matrices provided by the user and either add or multiply them together as stated by the user. Specifically the program must do the following: i) Write to the screen the name of the program ii) Ask the user which matrix operation is desired, either addition or multiplication. Specifically the operations are: A+B AB iii) Allowable matrix sizes will be up to 10 x 10 but no greater. USE IMPLICIT NONE iv) Check that the specified operation is possible. If not, indicate this problem to the user and close the program. vi) Conduct the specified matrix operation on A and B. The addition and the multiplication must be conducted in separate subroutines from each other and from the code requesting which operation to be conducted. vii) Write the resulting matrix to the screen in a matrix format (i.e. in rows and columns as the numbers occur within the matrix).Explanation / Answer
#include #include using namespace std; template class matrix { int row,col; M **ptr; public: matrix();//constructor ~matrix();//dest void operator +(matrix&); void operator *(matrix&); void show(); }; template matrix ::matrix() { input: coutrow; if(row>0) { coutcol;} if (col>0){ ptr=new M *[row]; for(int i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.