MATRIX ADDITION IN CPP SOURCE CODE

/*MATRIX ADDITION.CPP*/
#include "calculator.h"
#include <iostream>
using namespace std;
void ScientificCalculator::matrix_addition()
{
   cout<<"   WELCOME TO THE MATRIX ADDITION PORTION."<<endl;
   cout<<endl;
   int c, d, first[10][10], second[10][10], sum[10][10];
   cout<<"Enter the number of rows and columns of matrix ";
   cin>>a>>b;
   cout<<"    Enter the elements of first matrix: "<<endl;
   for(c = 0 ; c < a ; c++)
      for(d = 0 ; d < b ; d++)
         cin >> first[c][d];
   cout<<"    Enter the elements of second matrix: ";
   for(c = 0 ; c < a ;c++)
      for(d = 0 ; d < b ; d++)
            cin>>second[c][d];
   for(c = 0 ; c < a ; c++)
      for(d = 0 ; d < b ; d++)
         sum[c][d] = first[c][d] + second[c][d];
   cout<<"  Sum of entered matrices: ";
   for(c = 0; c < a ; c++)
   {
      for(d = 0; d < b; d++)
         cout<<sum[c][d]<<"\t";
      cout<<endl;
   }
}

Comments

Popular posts from this blog

Scientific Calculator Project Proposal