Page 322 - computer science (868) class 11
P. 322

48                  for ( j = 0; j < s; j++)
                49                  {

                50                      System.out.print(sparr[i][j]+ "\t");
                51                  }

                52                  System.out.println();
                53              }

                54          }
                55
                56           public static void main()

                57          {

                58              Scanner sc = new Scanner(System.in);
                59              int n;
                60              System.out.println("Enter the size:");

                61              n = sc.nextInt();
                62              spiral ob= new spiral(n);

                63              ob.display();
                64          }

                65      }

              The output of the program is as follows:
              Enter the size:
              5
              1      2       3      4      5
              16     17      18     19     6
              15     24      25     20     7
              14     23      22     21     8
              13     12      11     10     9

                            Let’s Revisit

                    ♦ Arrays can be defined as a set of variables which contains values of same data types having same variable name but different
                   subscripts required to separate the values.
                    ♦ Two or more elements arranged row-wise containing separate subscript values indicating the position of the element is known
                   as single dimensional array or 1D array.
                    ♦ The total number of elements an array holds is the length of the array.
                    ♦ Searching is used to determine whether an element is present in the array or not.
                    ♦ Sorting is the process of arranging the elements either in the ascending or the descending order.
                    ♦ Insertion is the process of adding an element at any desired position in the array.

                    ♦ Deletion is the process of deleting or removing an element from the array from the given position.
                    ♦ Merging is the process of combining two or more than two arrays.


                320320  Touchpad Computer Science-XI
   317   318   319   320   321   322   323   324   325   326   327