Access over 20 million homework & study documents
search

matrix multiplicarion C program

Content type

User Generated

Subject

Programming

Type

Lab

Rating

Showing Page:
1/2
PROGRAM:
#include<stdio.h>
int main()
{
int i,j,k,m,n,p,q;
printf("\nEnter the number of rows of first matrix:\n");
scanf("%d",&m);
printf("Enter the number of columns of the first matrix:\n");
scanf("%d",&n);
printf("\nEnter the number of rows of the second matrix:\n");
scanf("%d",&p);
printf("\nEnter the number of columns of the second matrix:\n");
scanf("%d",&q);
if(n!=p)
{
printf("\nINVALID:number of columns of 1st matrix must be equal
to number of rows of 2nd matrix to be multiplied.\n");
exit(0);
}
int a[m][n],b[p][q],c[m][q];
printf("Enter %d elements of the first matrix:\n",(m*n));
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("The first matrix is:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
printf("Enter %d elements of the second matrix:\n",(p*q));
for(i=0;i<p;i++)
{

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up

Unformatted Attachment Preview

PROGRAM: #include int main() { int i,j,k,m,n,p,q; printf("\nEnter the number of rows of first matrix:\n"); scanf("%d",&m); printf("Enter the number of columns of the first matrix:\n"); scanf("%d",&n); printf("\nEnter the number of rows of the second matrix:\n"); scanf("%d",&p); printf("\nEnter the number of columns of the second matrix:\n"); scanf("%d",&q); if(n!=p) { printf("\nINVALID:number of columns of 1st matrix must be equal to number of rows ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really helpful material, saved me a great deal of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4