Page 387 - CA_Blue( J )_Class10
P. 387

12          }
                  13          for (i=0; i<3; i++)

                  14          {   for(j=0;j<4;j++)
                  15              {   System.out.print( ar[i][j]*ar[i][j] + " ");

                  16              }
                  17              System.out.println();

                  18          }
                  19      }

                  20  }

                 You will get the following output:
                 Enter a number : 1
                 Enter a number : 2
                 Enter a number : 3
                 Enter a number : 4
                 Enter a number : 5
                 Enter a number : 6
                 Enter a number : 7
                 Enter a number : 8
                 Enter a number : 9
                 Enter a number : 10
                 Enter a number : 11
                 Enter a number : 12
                 1 4 9 16
                 25 36 49 64
                 81 100 121 144

                  Program 7      To create an array of size 2 x 3 and print the factorial of all the numbers separately.


                   1  import java.util.*;

                   2  class array_double_factorial
                   3  {

                   4      public static void main()
                   5      {

                   6          Scanner sc= new Scanner(System.in);
                   7          int ar[][]=new int[2][3];

                   8          int i,j,k,f;
                   9          for (i=0; i<2; i++)

                  10          {   for(j=0;j<3;j++)



                                                                                                                       385
                                                                                                              Arrays   385
   382   383   384   385   386   387   388   389   390   391   392