104./*Write a program to input two dimensional array to
convert Row to Column and Column to Row and print transpose value*/
#include<stdio.h>
#include<conio.h>
main()
{
int arr1[3][3],arrt[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3
array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&arr1[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrt[i][j]=arr1[j][i];
}
}
printf("The transpose of the
matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("arrt[%d][%d] =
%d\t\t",i,j,arrt[i][j]);
}
}
getch();
}
OUTPUT
Enter a 3 X
3 array :
1
2
3
4
5
6
7
8
9
The
transpose of the matrix is
arrt[0][0]
= 1 arrt[0][1] = 4 arrt[0][2] = 7
arrt[1][0]
= 2 arrt[1][1] = 5 arrt[1][2] = 8
arrt[2][0]
= 3 arrt[2][1] = 6 arrt[2][2] = 9
No comments:
Post a Comment