Page 278 - Computer science 868 Class 12
P. 278

09


                                                                                      ARRAYS

















                      Learning Objectives

                  9.1  Array                                        9.2  Single-Dimensional Array/One-Dimensional Array
                  9.3  Basic Operation on Array                     9.4  Length of the Array
                  9.5  Double-Dimensional Array
                  9.6   Address Calculation in One-Dimensional Array and Two-Dimensional Array


              This chapter deals with structured data types – arrays (single and multidimensional), address calculations, different
              Sorting techniques (bubble, selection, insertion) and Search techniques (Linear and Binary Search)


                   9.1 ARRAY
              Sometimes it becomes necessary to work with large volumes of data of the same type. So, they have to be stored in
              an economical way in such a manner the program code reduces and the memory space is used in an optimum way as
              shown below.
              Let us take the following situation.
              There are 25 students in a coaching centre. The teacher wants to store the names of the students in an organised way
              so that it becomes easy for him. He stores them in separate variables.

                  import java.util.*;
                  class student
                  {
                      public static void main()
                      {
                          Scanner sc= new Scanner(System.in);
                          String a1,a2,a3,a4.....,a25;
                          System.out.println("Enter the name of the students one by one");
                          a1=sc.next();
                          a2=sc.next();
                          .
                          .
                          System.out.println(a1);
                          System.out.println(a2);
                          .
                          .
                      }
                  }

                276276  Touchpad Computer Science-XII
   273   274   275   276   277   278   279   280   281   282   283