10 Mar 2013

Multiply Matrix

/*

program to multiply two matrices...

*/

#include<iostream.h>
#include<conio.h>
 

void main()
{
 

clrscr();
int x[50][50],y[50][50],z[50][50],i,j,k,a,b,c,d,e,f,g,h;
 

cout<<"Enter the rows and columns for first matrix:"<<endl;
cin>>i>>j;
cout<<"Enter the rows and columns for second matrix:"<<endl;
cin>>k>>a;
cout<<"Enter the elements of the first matrix:"<<endl;
for(b=0;b<i;b++)
for(c=0;c<j;c++)
 {
  cin>>x[b][c];
 }
cout<<"Enter the elements of the second matrix :"<<endl;
for(b=0;b<k;b++)
for(c=0;c<a;c++)
 {
  cin>>y[b][c];
 }
cout<<endl<<endl<<"The corresponding first matrix is:"<<endl;
for(b=0;b<i;b++)
 {
  cout<<endl;
  for(c=0;c<j;c++)
   {
    cout<<x[b][c]<<'\t';
   }
 }
cout<<endl<<endl<<"The corresponding second matrix is:"<<endl;
for(b=0;b<k;b++)
 {
  cout<<endl;
  for(c=0;c<a;c++)
   {
    cout<<y[b][c]<<'\t';
   }
 }
cout<<endl<<endl<<"The product matrix is:"<<endl;
for(b=0;b<i;b++)
 {
  cout<<endl;
  for(c=0;c<a;c++)
   {
    z[b][c]=0;
    for(h=0;h<j;h++)
     {
      z[b][c]+=x[b][h]*y[h][c];
      cout<<z[b][c]<<'\t';
     }
   }
 }


getch();
}

Categories: , , ,

Related Posts:

  • Bonus_SOLVED /*CODECHEFPROBLEM CODE : ACMKANPB*/#include <stdio.h> int main(){int fall, i, c, n, m, l, t, j, x[4][10100]; for(scanf("%d",&fall); fall--;) { for(i=!!scanf("%d %d %d",&n,&m,&l); i<=m; x[0][i… Read More
  • The Next Palindrome_SOLVED /* CODECHEF PROBLEM CODE : PALIN */ #include <stdio.h> #include <stdlib.h> #include <string.h> char K[1000002]; int flag; int main()  { int t,i; scanf("%d\n",&t); for(i=… Read More
  • The Matrix Game_SOLVED /* CODECHEF PROBLEM CODE : SNCK01 */ #include <stdio.h> #define N 51 int M[N][N]; int main() { int n,m,sg,t,r,i,j; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(i=… Read More
  • Tautology_SOLVED /* CODECHEF PROBLEM CODE : TAUT */ #include <stdio.h> #include <string.h>#define S(a,b,c) (b=(a)?(c):(b)) int f[30];char z[3][130]; int A(int q, int w){if(q>=w) return B()+(f[28]=0);if(!… Read More
  • Logging Game_SOLVED /*CODECHEFPROBLEM CODE : LOGGERS */#include<stdio.h>  int sgtable[251]={… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger