Search:

Submit Article

# Program to multiply two matrices using thread

Posted By: Easy Tutor     Category: C Programming     Views: 52415

## Code for Program to multiply two matrices using thread in C Programming

```# include <stdio.h>

int MAT1[10][10];
int MAT2[10][10];
int MAT3[10][10];

int r1,c1,r2,c2;

int main()
{
int iCount,jCount,kCount;

printf("Enter Number of Rows For Matrix 1 :");
scanf("%d",&r1);

printf("Enter Number of Columns For Matrix 1 :");
scanf("%d",&c1);

for(iCount=0;iCount<r1;iCount++)
{
for(jCount=0;jCount<c1;jCount++)
{
printf("Enter Mat1[%d][%d] :",iCount,jCount);
scanf("%d",&MAT1[iCount][jCount]);
}
}

printf("\n");

printf("Enter Numer of Rows For Matrix 2 :");
scanf("%d",&r2);

printf("Enter Number of Columns For Matrix 2 :");
scanf("%d",&c2);

for(iCount=0;iCount<r2;iCount++)
{
for(jCount=0;jCount<c2;jCount++)
{
printf("Enter Mat2[%d][%d] :",iCount,jCount);
scanf("%d",&MAT2[iCount][jCount]);
}
}

if(c1!=r2)
{
printf("Multipication of Matrix not Possible !!!");
}
else
{
for(iCount=0;iCount<r1;iCount=iCount+2)
{
for(jCount=0;jCount<c2;jCount=jCount+2)
{
MAT3[iCount][jCount]=0;
}
}

for(iCount=0;iCount<r1;iCount=iCount+2)
{
for(jCount=0;jCount<c2;jCount++)
{
for(kCount=0;kCount<c1;kCount++)
{
MAT3[iCount][jCount]+=MAT1[iCount][kCount] * MAT2[kCount][jCount];
}
}
}

}

printf("\n Matrix 1 \n");

for(iCount=0;iCount<r1;iCount++)
{
for(jCount=0;jCount<c1;jCount++)
{
printf("%d \t",MAT1[iCount][jCount]);
}
printf("\n");
}

printf("\n Matrix 2 \n");

for(iCount=0;iCount<r2;iCount++)
{
for(jCount=0;jCount<c2;jCount++)
{
printf("%d \t",MAT2[iCount][jCount]);
}
printf("\n");
}

printf("\n Multipication of Matrix ...\n");

for(iCount=0;iCount<r1;iCount++)
{
for(jCount=0;jCount<c2;jCount++)
{
printf("%d \t",MAT3[iCount][jCount]);
}
printf("\n");
}
return 0;
}

{
int iCount,jCount,kCount;
for(iCount=1;iCount<r1;iCount=iCount+2)
{
for(jCount=0;jCount<c2;jCount++)
{
for(kCount=0;kCount<c1;kCount++)
{
MAT3[iCount][jCount]+=MAT1[iCount][kCount] * MAT2[kCount][jCount];
}
}
}

}
```
Share:

Didn't find what you were looking for? Find more on Program to multiply two matrices using thread Or get search suggestion and latest updates.

 Easy Tutor author of Program to multiply two matrices using thread is from United States. Easy Tutor says Hello Friends,I am Free Lance Tutor, who helped student in completing their homework. I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] comI have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada. I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.Thanks,Happy Programming :) View All Articles