Page 362 - CA_Blue( J )_Class10
P. 362
15
ARRAYS
Learning Objectives
15.1 What is an Array? 15.2 Types of Arrays 15.3 Length of an Array
15.4 Single Dimensional Array and Double Dimensional Array
15.5 Different Operations on Array 15.6 Sorting and Searching
Till now, you have created various programs in the previous chapters. You have used variables to store values. Only
a single value can be stored in a variable at a time. But sometimes, we may require a large number of variables of
same type to store several values. For example, a class contains 40 students. Each student has a unique name and roll
number. To store these names and roll numbers, we need a total of 80 variables. It becomes very difficult to maintain
the flow of the program with too much variables. In such cases, the concept of array becomes very helpful. Using
array, a large amount of data can be handled very efficiently. Thus, giving way to appropriate utilisation of memory
and effective variable usage.
15.1 WHAT IS AN ARRAY?
An array can be defined as a set of values of same data type having a single variable name. It is a reference data type as
it is created with the help of primitive data types. It helps to store a number of values of similar type in a single variable.
An array makes a program easy to read and understand as it can store values of several variables in a single variable.
It reduces the size of a program and also reduces the efforts of a programmer as he does not need to declare and
maintain several variables in a program. Earlier, we need a separate variable to store different values of same type.
Let us consider the previous example where we need to store the names of 40 students. To store names of 40 students,
we need 40 variables of String type:
String St1_Name, St2_Name, St3_Name, St4_Name, …, St40_Name;
We need to assign the values of all the names to these variables as:
St1_Name = "Deepak";
St2_Name = "Komal";
St3_Name = "Divya";
St4_Name = "Chirag";
……
……
360360 Touchpad Computer Applications-X

