You are on page 1of 2

21 September 2021

(a) Write a program to initialise an array Name to hold 20 names with “Empty”

Empty Empty Empty


1 2 3 4 20
Name

Dim Name(20) as string


Dim index as integer

For Index = 1 to 20 This part initialises the array Name to Empty


Name(index) = “Empty”
Next

(b) Write a program to initialise an array Age to hold 20 ages with 18

Dim Age(20) as integer


Dim Index as integer

For index = 1 to 20
Age(index) = 18
Next

(c) Write a program to initialise the array num to hold 10 numbers in sequence of 1,2,3…

1 2 3 4
Cell 1 2 3 4 10
Dim num(10) as integer
Dim num(10) as integer Dim i, count as integer
Dim I as integer Count = 1
For i = 1 to 10
For I = 1 to 10 Num(i) = count
Num(i) = i Count = count + 1
Next Next
(d) Write a program to initialise the array Number to hold 50 numbers in sequence of 1,3,5,7,9…

1 3 5 7 9
Cell 1 Cell 2 Cell 3 Cell 4 10

Dim Number(50) as integer


Dim Index, count as integer

Count = 1
For index = 1 to 50
Number(Index) = count
Count = count + 2
Next
(e) Write a program to initialise the array Number to hold 70 even numbers in sequence of
5,10,15,20,25…

5 10 15 20 25
Cell 1 Cell 2 Cell 3 Cell 4 10

Dim Number(70) as Integer


Dim i, count as integer

Count = 5
For i = 1 to 70
Number(i) = count
Count = count + 5
Next

You might also like