You are on page 1of 2

Name: Talha Amin

Enrollment no: 02-235191-015 Lab 7 Date: 3/27/2019

LAB-7

Task1:

Source Code:
#include <iostream>
using namespace std;
int main()
{
int A[2][2], B[2][2], C[2][2];
cout << "Enter Elements of Matrix A" << endl;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
cin >> A[i][j];
}
cout << "Enter Elements of Matrix B" << endl;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
cin >> B[i][j];
}
cout << "Sum of two matrices is :"<< endl;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
C[i][j] = A[i][j] + B[i][j];
cout << C[i][j] << endl;

return 0;
}

Snapshot:
Name: Talha Amin
Enrollment no: 02-235191-015 Lab 7 Date: 3/27/2019

Task3:

Source Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int A[4][3], B[4][3] ;
cout << "Enter Elements of Matrix A" << endl;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 3; j++)
{
cin >> A[i][j];
}

cout << "Elements of Matrix A are " << endl;


for (int i = 0; i < 4; i++)
for (int j = 0; j < 3; j++)
{
cout << A[i][j] << " ";
cout << "\n";
}
for (int i = 0; i < 4; i++)
for (int j = 0; j < 3; j++)
{
B[i][j] = A[i][j] / 5;
}
cout << "Elements of A after divided by 5" << endl;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 3; j++)
{
cout << B[i][j] << " ";
}
return 0;
}

Snapshot:

You might also like