Code Below:


class transposematrix
{
    public static void main()
    {
        int dda[][]={{1,4,7},{2,5,8},{3,6,9}};                  //MANUALLY INPUTTING VALUES IN DDA
        int r,c;
        for (r=0;r< 3;r++)
        {
            for (c=0;c< 3;c++)
            {
                System.out.print(dda[r][c]+"\t");
            }
            System.out.println();
        }
        int trn[][]=new int[3][3];
        for (r=0;r< 3;r++)
        {
            for (c=0;c< 3;c++)
            {
                trn[c][r]=dda[r][c];
            }
        }
        System.out.println("The Transpose Matrix");
        for (r=0;r< 3;r++)
        {
            for (c=0;c< 3;c++)
            {
                System.out.print(trn[r][c]+"\t");
            }
            System.out.println();
        }
    }
}