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

Implement a C++ class to model the mathematical operations of a matrix. Your cla

ID: 3863088 • Letter: I

Question

Implement a C++ class to model the mathematical operations of a matrix. Your class should include the following functions. add() which adds two matrices; power() which raises the first matrix to power n; == which returns true if both matrices are equal. You need to overload the C++ equality operator. A sample run follows. Enter the number of rows: 2 Enter the number of columns: 3 Enter the elements of matrix 1 row by row: 1 0 3 5 1 2 Enter the elements of matrix 2 row by row: 1 1 2 1 0 4 matrix 1 + matrix 2? No matrix 1 + matrix 2: 2 1 5 6 1 6 matrix 1 power n. Enter n: 2 1 0 9 25 1 4

Explanation / Answer

Add two matrix:

#include<iostream.h>

#include<conio.h>

void main()

{

int a[50][50],i,j,r,c;

clrscr();

cout<<"Enter the no of row sand columns:");

cin>>r>>c;

cout<<"Enter the Elements for A:";

for(i=0;i<i;i++)

{

for(j=0;j<j;j++)

{

cin>>a[i][j];

}

}

cout<<"Enter the elements for B:");

for(i=0;i<r;i++)

for(j=0;j<c;j++)

cin>>b[i][j];

for(i=0;i<r;i++)

for(j=0;j<c;j++)

d[i][j]=a[i][j]+b[i][j];

printf("Array Elements are:");

for(i=0;i<r;i++)

{

for(j=0;j<c;j++)

cout<<d[i][j];

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote