Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

Program of matrix multiplication using function

Posted By: Raymund Fischer     Category: C Programming     Views: 25886

Write a program of matrix multiplication using function.

Code for Program of matrix multiplication using function in C Programming

#include<stdio.h>
#include<conio.h>

void read_arr(int a[10][10],int row,int col)
{
    int i,j;
    for(i=1;i<=row;i++)
    {
    for(j=1;j<=col;j++)
    {
        printf("Enter Element %d %d : ",i,j);
        scanf("%d",&a[i][j]);
            }
    }
}

void mul_arr(int m1[10][10],int m2[10][10],int m3[10][10],int row,int col)
{
    int i,j,k;
    for(i=1;i<=row;i++)
    {
    for(j=1;j<=col;j++)
    {
    for (k=1;k<=row;k++)
    {
    m3[i][j] = m3[i][j] + (m1[i][k] * m2[k][j]);
    }
    }
    }
}

void print_arr(int m[10][10],int row,int col)
{
    int i,j;
    for(i=1;i<=row;i++)
        {
        for(j=1;j<=col;j++)
        {
            printf("%d ",m[i][j]);
         }
        printf("\n");
        }
}

main()
{
    int m1[10][10],m2[10][10],m3[10][10],row,col;
    clrscr();
    printf("Enter number of rows :");
    scanf("%d",&row);
    printf("Enter number of colomns :");
    scanf("%d",&col);
    read_arr(m1,row,col);
    read_arr(m2,row,col);
    mul_arr(m1,m2,m3,row,col);

    print_arr(m3,row,col);
    getch();
}
  
Share: 


Didn't find what you were looking for? Find more on Program of matrix multiplication using function Or get search suggestion and latest updates.

Raymund Fischer
Raymund Fischer author of Program of matrix multiplication using function is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!