Here is my source code of inputting and print the matrix:
#include<stdio.h>
int main(void)
{
unsigned int m,n;
int a[10][10];
int i,j;
int temp;
printf("Plz enter the number of rows of Matrix:\n");
scanf("%d",&m);
printf("Plz enter the number of columns of Matrix:\n");
scanf("%d",&n);
printf("Enter elements for the Matrix:\n");
for(i=0; i<m ;i++)
for(j=0; j<n; j++)
{
printf("Element[%d][%d] is: ",i,j);
scanf("%d",&temp);
a[i][j]=temp;
}
printf("The Matrix is:\n");
for(i=0; i<m ;i++)
{
for(j=0; j<n ; j++)
printf("%d ", a[i][j]);
printf("\n");
}
getch();
return 0;
I don't know the difference between the direct entering value for element of matrix:
printf("Enter elements for the Matrix:\n");
for(i=0; i<m ;i++)
for(j=0; j<n; j++)
{
printf("Element[%d][%d] is: ",i,j);
scanf("%d",&a[i][j]);
}
and through the temporary like code before:
printf("Enter elements for the Matrix:\n");
for(i=0; i<m ;i++)
for(j=0; j<n; j++)
{
printf("Element[%d][%d] is: ",i,j);
scanf("%d",&temp);
a[i][j]=temp;
}
Because when running both of them runs very well without any bugs.