PF 2 Assignment
PF 2 Assignment
Section: (S)
Subject: PF - 2
Q1. Take the size of two matrices from user. Input value of both matrices from
user. For addition the size of both matrices must be same. Take the value of
both the matrices and add them store and display the result in a third matrix.
#include <iostream>
using namespace std;
int main()
{
int r, c, a[50][50], b[50][50], sum[50][50], i, j;
cout << "Enter rows = ";
cin >> r;
cout << "Enter columns = ";
cin >> c;
cout << endl <<"Elements of 1st matrix " << endl;
cout << endl << "Elements of 2nd matrix " << endl;
for(i = 0; i < r; ++i)
for(j = 0; j < c; ++j)
{
cout <<"Enter element b" << i + 1 << j + 1 << " : ";
cin >> b[i][j];
}