when i am running this program no errors are being shown butas soon as i press ctr+f9 to run the program my tc++ window closes..... please help me find out the problem....
Code:
#include<stdio.h>
#include<conio.h>
void multiply(int m1[50][50],int ,int,int m2[50][50],int ,int );
void main()
{
int i,j,m,n,p,q,m1[50][50],m2[50][50];
printf("Enter the dimensions of the matrix1:");
scanf("%d %d",&m,&n) ;
printf("enter the matrix1\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&m1[i][j]);
}
printf("Enter the dimensions of the matrix2:") ;
scanf("%d %d",&p,&q);
printf("enter the matrix 2\n");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
scanf("%d",&m2[i][j]);
}
multiply( m1,m,n,m2,p,q);
}
void multiply(int m1[][50],int m,int n,int m2[][50],int p,int q)
{
int i,j,k,m3[50][50];
if(n!=p)
printf("you have entered incorrect dimensions...the matrices cannot be multiplied:\n");
else
{
for(i=0;i<q;i++)
{
for(j=0;j<m;j++)
{
m3[j][i]=0;
for(k=0;k<n;k++)
m3[j][i] = m3[j][i] + (m1[j][k]*m2[k][i]);
}
}
printf("the multiplication of the 2 matrices gives the following result:\n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
printf(" %d",m3[i][j]);
printf("\n");
}
}
}