Академический Документы
Профессиональный Документы
Культура Документы
ARRAYS
CLASS 10TH
ARRAYS
Chapter No. 4 English Medium
Class 10th
Zeeshan
Visit: www.zeeshanfaizali.blogspot.com
Notes Prepared By Zeeshan Faiz
Visit:www.zeeshanfaizali.blogspot.com
1|Page
CHAPTER No. 4
ARRAYS
CLASS 10TH
Short Questions
1) Why we need an array?
If we have to use hundred and thousands of different variables in a program, it will become
difficult to handle them. For example to store names of hundred students in a computer. It needs
hundred different variable names. So an array can solve this problem by defining the same type
of variable under the same name with different reference number.
2) Define an array.
An array is a collection of variables that can store data of same type. Each memory location
holds a single value which is called an element of an array. The general syntax of array is:
Array name (size of array)
For example: A(4) and B$(5).
3) What is element of the array?
The array is represented in the computers memory by a set of consecutive memory locations.
These memory locations are referred to as elements of the array.
4) What is index or subscript?
Each array is given a name and the elements of the array are accessed with reference to their
position or location number. This position number is called index or subscript. The subscript or
index value is written in parenthesis with the name of array.
5) Why array is called subscript variable?
An array is called a subscript variable because when we need to access a certain element; we
must use a subscript to point to that element so we can differentiate it from the rest. All array
elements in an array have the same variable name, which is also the name of the entire array.
6) How values can be assigned to array?
Values can be assigned to the subscripted variable or array by LET statement, READ . DATA
statement or INPUT statement. The size of subscript / index value can be a variable or number or
a numeric expression.
7) Write a program to describe the filling and printing of an array using READ DATA.
5 N$(4)
10 FOR K=1 TO 4
20 READ N$(K)
30 PRINT N$(K)
40 NEXT K
50 DATA Ali, Hamza, Ahsan, Moiz
60 END
8) Write a program to describe the filling and printing of an array using INPUT statement.
5 N$(4)
10 FOR K=1 TO 4
20 INPUT Enter the name of student= , N$(K)
30 NEXT K
40 FOR K=1 TO 4
50 PRINT N$(K)
60 NEXT K
70 END
9) Write syntax and purpose of DIM statement.
By default GWBASIC provides an array for storing 10 elements, from subscript 0 to 9. If we
need to store more than 10 values in an array we use DIM statement with that array. DIM stands
for DIMENSION.
Syntax: Line No. DIM subscripted variable1, subscripted variable2,
2|Page
CHAPTER No. 4
ARRAYS
CLASS 10TH
3|Page
CHAPTER No. 4
ARRAYS
CLASS 10TH
4|Page
CHAPTER No. 4
ARRAYS
CLASS 10TH
A subscript in an array is used to locate or access the elements of the array that are already stored
in it. Or it is also used to locate that position where element will be stored.
6. How would you Fill and Print the array?
Answer from question No. 8.
7. What is meant by array manipulation?
Answer from question No. 22.
8. Differentiate between 1-D array and 2-D array.
1-D Array
2-D Array
1. One dimensional array is like list where there
can only be one row or column.
2. This type of array needs only one loop to fill
and print its elements.
3. Only one subscript is requires to represents the
elements of the array.
4. Require DIM keyword if more than 10
elements need to be stored.
5. Syntax:
Line No. [DIM] arrayname(size of array)
6. E.g.
N(10), DIM A(20)
9. Describe about the printing two-dimensional array with the help of an example.
Answer from question No. 18,19,20,21.
10. Write a program in BASIC to enter integer type data into an array and then to print the
values in the reverse order.
10
CLS
20
DIM N(10)
30
PRINT ENTER TEN VALUES
40
FOR K=1 TO 10
50
INPUT ENTER NUMBER= ,N(K)
60
NEXT K
70
PRINT NUMBERS IN REVERSE ORDER
80
FOR M=10 TO 1 STEP -1
90
PRINT N(M)
100
NEXT M
110
END
11. Differentiate between simple and subscript variable.
Simple variable
Subscript variable
1. It can store only one data element.
2. Every simple variable has a unique name that
distinguishes them from the rest.
3. It is also called variable.
4. Syntax:
Variablename = data element
5. E.g.
SUM = A + B, PRO = SUM * 4, A= 3
5|Page
CHAPTER No. 4
ARRAYS
CLASS 10TH
6|Page
CHAPTER No. 4
30
40
50
60
70
80
90
100
110
ARRAYS
CLASS 10TH
LET SUM = 0
PRINT ENTER 12 NUMBERS
FOR K=1 TO 20
INPUT ENTER NUMBER= , Z(K)
SUM = SUM + Z(K)
NEXT K
PRINT SUM OF GIVEN NUMBERS= ;SUM
PRINT AVERAGE OF GIVEN NUMBERS= ;SUM/12
END
7|Page