Matrix Multiplication in C-Language and Dataflow graph

Program:

# include "stdio.h"
main()
{
    int m1[10][10],i,j,k,m2[10][10],mult[10][10],r1,c1,r2,c2;

  1.     printf("Enter number of rows and columns of first matrix (less than 10)\n");
  2.     scanf("%d%d",&r1,&c1);
  3.     printf("Enter number of rows and columns of second matrix (less than 10)\n");
  4.     scanf("%d%d",&r2,&c2);
  5.     if(r2==c1)
  6.     {
  7.         printf("Enter rows and columns of First matrix \n");
  8.         for(i=0;i<r1;i++)
  9.         {
  10.             for(j=0;j<c1;j++)
  11.                 scanf("%d",&m1[i][j]);
  12.         }
  13.         printf("Enter rows and columns of Second matrix \n");
  14.         for(i=0;i<r2;i++)
  15.         {
  16.             for(j=0;j<c2;j++)
  17.                 scanf("%d",&m2[i][j]);
  18.         }
  19.         printf("Multiplication of the Matrices:\n");
  20.         for(i=0;i<r1;i++)
  21.         {
  22.             for(j=0;j<c2;j++)
  23.             {
  24.                 mult[i][j]=0;
  25.                 for(k=0;k<r1;k++)
  26.                     mult[i][j]+=m1[i][k]*m2[k][j];
  27.                 printf("%d\t",mult[i][j]);
  28.             }
  29.         }
  30.     }
  31.     else
  32.     {
  33.         printf("Matrix multiplication cannot be done");
  34.     }
  35. }


Data flow graph
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...
 
Posts RSSComments RSSBack to top
© 2013 Updated Tech News Results and Reviews