CS201 ASSIGNMENT 2 SOLUTION 2023
cs201 assignment 2 solution 2023,cs201 assignment 2 2023,cs201,cs201 assignment 1 solution 2022,cs201 assignment 2022,cs201 assignment,cs201 assignment 1 2022,cs201 assignment 1,cs201 p assignment 2 2022,cs201p assignment 2 2022,cs201 assignment solution 2022,cs201 assignment 2 solution 2022,cs201 assignment 2,cs201 assignment solution,cs201 assignment 1 solution,cs201 assignment 2 2022,cs201 assignment 1 solution fall 2022,cs201 assignment no 2 2023
SOLUTION FIILE LINK BELOW
CS201 Assignment 2 Solution Fall 2022-2023
Solution:
#include<iostream>
using namespace std;
class Matrix Property {
private:
int matrix[2][2];
public:
MatrixProperty(){
for (int i=0;i<2:1++){ for (int j=0;j<2: j++) { matrix[1][j] = 0;
}
}
MatrixProperty(int a[2][2]) {
setMatrix(arr):
{
void setMatrix(int arr[2][2]) {
for (int i=0;i<2:++) {
for (int j=0;j<2;j++) { matrix[1][j] = arr[i][j];
}
}
}
friend MatrixProperty Transpose MatrixProperty &m) {
MatrixProperty transpose:
for (int i=0;i<2:1++){
for (int j=0;j<2: j++){
transpose matrix[i][j] = m.matrix[j][i];
retum transpose:
MatrixProperty operator+(const MatrixPropaty &m) {
MatrixProperty result;
for (int i=0:1-2:++) { for (int j=0;j<2; j++){
result.matrix[i][j] = matrix[i][j] +m_matrix[i][j];
}
}
return result;
}
void display(MatrixProperty &m) {
for (int i=0;i<2:i++) {
for (int j=0;j<2; j++) {
cout<<m.matrix[i] <<“”;
}
cout << endl;
}
}
};
int main() {
int A[2][2]={(1, 2), (3,4));
int B[2][2] ((5.6), (7,8));
MatrixProperty matl, mat2, mat3, mat4:
mat 1.setMatrix(A);
mat2.setMatrix(B);
mat3 = mat1 + mat2;
mat4 Transpose(mat3);
cout<<” “<<<<endl:
cout<<<<” “<<<<endl:
cout<<<<” ——————————————————————————-
———————- “<<<<endl:
cout<<“Matrix A:”;
cout<<endl;
mat1.display(mat1);
cout<<“Matrix B:
cout<<endl;
mat2.display(mat2);
cout<<“Sum of Matrix A and B: “:
cout<<endl;
mat3.display(mat3);
cout<<“Transpose of Matrix (A+B): “:
cout<<endl;
mat4.display(mat4);
return 0;
}