#include<stdio.h>
void matmultiply(int m[3][3], int n[3][3]);
void read(int x[3][3]);
//void read2(int y[3][3]);
void main()
{
int a[3][3],b[3][3],l,w;
printf("\nFor matrix a :-\n");
read(a);
printf("\nFor matrix b :-\n");
read(b);
printf("\nMatrix a :\n");
for(l=0;l<3;l++)
{
for(w=0;w<3;w++)
{
printf("%d\t",a[l][w]);
}
printf("\n");
}
printf("\nMatrix b :\n");
for(l=0;l<3;l++)
{
for(w=0;w<3;w++)
{
printf("%d\t",b[l][w]);
}
printf("\n");
}
matmultiply(a,b);
getch();
}
void read(int x[3][3])
{
int r,s;
for(r=0;r<3;r++)
{
for(s=0;s<3;s++)
{
printf("Enter the [%d][%d]th element of matrix : ",r,s);
scanf("%d",&x[r][s]);
}
}
}
void matmultiply(int m[3][3], int n[3][3])
{
int t[3][3],i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
t[i][j]=0;
for(k=0;k<3;k++)
{
t[i][j]=t[i][j]+m[i][k]*n[k][j];
}
}
}
printf("\nThe resultant matrix after multiplying is :-\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",t[i][j]);
}
printf("\n");
}
}
Monday, July 31, 2017
Home »
C Programming
» Code in C to multiply two matrix
Code in C to multiply two matrix
Related Posts:
Find HCF in C#include<stdio.h> int hcf(int a,int b,int c) { if(a%c==0 && b%c==0) return c; hcf(a,b,c-1); } void main() { int h,x,y; printf("Enter two numb… Read More
Find fibonacci series in C#include<stdio.h> void fibonacci(int); void main() { int n,first=0,second=1; printf("Enter the number of fibonacci series to be printed : "); scanf("%d",&n); p… Read More
Find triangular no. in C#include<stdio.h> void main() { int n1,n2,i,t; printf("Enter two numbers : "); scanf("%d%d",&n1,&n2); for(i=1;i<=n2;i++) { &… Read More
Check if a no. is prime or not in C ?#include<stdio.h> int testprime(int ,int); void main() { int n,prime; printf("Enter a positive number : "); scanf("%d",&n); prime=testprime(n,n/2); &nbs… Read More
Find no. of vowels in a string in C #include<stdio.h> void strcount(char []); void main() { char str[50]; char c; while(1) { printf("enter string\n"); //gets(str); scanf("%s",str); &nb… Read More
0 comments:
Post a Comment