My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to find the product of matrix

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int a[50][50],b[50][50],c[50][50],p,q,r,s;
 cout<<"enter the rows and columns of first matrix"<<endl;
 cin>>p>>q;
 cout<<"enter the elements of first matrix"<<endl;
 for(int i=0;i<p;i++)
  for(int j=0;j<q;j++)
   cin>>a[i][j];
 cout<<"first matrix is"<<endl;
 for(i=0;i<p;i++)
  {
   for(j=0;j<q;j++)
   cout<<a[i][j]<<'\t';
   cout<<endl;
   }
 cout<<endl<<endl;
 cout<<"enter the rows and columns of second matrix"<<endl;
 cin>>r>>s;
 cout<<"enter the elements of second matrix"<<endl;
 for(i=0;i<r;i++)
  for(j=0;j<s;j++)
  cin>>b[i][j];
  cout<<"second matrix is"<<endl;
  for(i=0;i<r;i++)
  {
   for(j=0;j<s;j++)
   cout<<b[i][j]<<'\t';
   cout<<endl;
  }
  if(q==r)
  {
    for(i=0;i<p;i++)
     for(j=0;j<s;j++)

0 comments: