#include<stdio.h>
#include<math.h>
int main()
{
int m,n,p,i,j,a[5][5];
printf("Enter no. of rows & colomns of the matrix\n");
scanf("%d%d",&m,&n);
if(n==0 || m==0)
{
printf("Matrix multiplication is not possible");
exit(0);
}
printf("Enter elements into matrix\n");
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
scanf("%d",&a[i][j]);
}
}
printf("The Matrix is:\n");
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("Enter a number to multiply\n");
scanf("%d",&p);
printf("The Matrix multiplication is:\n");
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
printf("%d\t",p*a[i][j]);
}
printf("\n");
}
return 0;
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter no. of rows & colomns of the matrix
2
2
Enter elements into matrix
1
2
3
4
The Matrix is:
1 2
3 4
Enter a number to multiply
5
The Matrix multiplication is:
5 10
15 20