Page 336 - Cs_withBlue_J_C11_Flipbook
P. 336

3       {
                4           public static void main()

                5           {
                6               Scanner sc= new Scanner(System.in);

                7               int i, j;
                8               int ar[ ][ ]=new int[3][3];

                9               int tar[ ][ ]=new int[3][3];
                10              for (i=0; i<3; i++)
                11              {

                12                   for(j=0; j<3; j++)

                13                   {
                14                         System.out.print("Enter a number: ");
                15                         ar[i][j] =sc.nextInt();

                16                   }
                17              }

                18              System.out.print("Original Array:\n ");
                19              for (i=0; i<3; i++)

                20              {
                21                   for(j=0; j<3; j++)

                22                   {
                23                         System.out.print(ar[i][j]+" ");

                24                   }
                25                   System.out.println();

                26              }
                27              for (i=0; i<3; i++) // Transposing the Array

                28              {
                29                   for(j=0; j<3; j++)

                30                   {
                31                         tar[i][j]=ar[j][i];

                32                   }
                33              }

                34              System.out.println("Transposed Array:");
                35              for (i=0; i<3; i++)
                36              {





                334334  Touchpad Computer Science-XI
   331   332   333   334   335   336   337   338   339   340   341