Arrays 221
{
in t i, j,rcw,col,a[10] [10];
clrscrO ;
printf ("tt Enter Order of matrix up to(10x 10) A:");
scanf (“%d %d",&row,txcol};
printf ("Enter Elements of matrix A : ft");
for (i=0,i<rowrf++)
for (j=0,mj<col,j++)
scanf ("%d",&a[i][j]);
printf ("n The Matrix is:
");
for (i=$,'i<row,'i++)
I
for (j=0,j<col,-j++)
printf C%6d",a[i][fl);
printf ("n");
}
QUTPUX:
Enter Order of matrix up to (10 x 10) A : 3 3
Enter Elements of matrix A :
3 5 8
4 8 5
8 5 4
The Matrix is:
3 5 8
4 8 5
8 5 4
Explanation In the above program the order of the matrix is entered. The order of the matrix should
be up to 10 x 10. For the sake of understanding we have taken 3 x 3 matrix. Using first two nested
fo r loops with respect to rows and columns the elements of matrix are entered. The last two nested for
loops are used for displaying the matrix elements with respect to row and column.
Transpose of the matrix The Transpose of matrix interchanges rows & columns, i.e. The row
elements become column elements and vice versa.
7.28 Read the elements of the matrix of the order up to 10 x 10 and transpose its elements.
# include <stdio.h>
# include <conio.h>
void main ()
{
int i.j,rcwl,row2,coll,col2,a[10][10],b[10][10];
clrscrO ;
printf ("
Enter Order of matrix up to (10X10) A :");