Kamis, 02 April 2020

SMALL BASIC: Programming question session 2

1. If you have an array like below, what is the length of the array, notice the index 0 of the array is empty or "", i.e. What is the output of textwindow window?

myarr[0] = ""
myarr[1] = "A"
myarr[2] = "B"
TextWindow.WriteLine(Array.GetItemCount(myarr))

A). 1 B). 2 C). 3

2. Still with code from number  1


3. Logic question: Mr. Bono told to record all the room number that are not empty and handed that record to Mr. Bing, because Mr. Bing wants to knock every door's room, meet and invite every room user to have a tea while talk with him/her about the rise of the rent.

But,

4). Look for the code below, I want to add fgd array's element to nbr array's element. Do you think the nbr array elements grows or appended with fgd elements forever?

fgd[0] = "Added"
fgd[1] = "Added"
nbr[0] = 0
nbr[1] = 1

start:

nbr_l = array.GetItemCount(nbr)
TextWindow.WriteLine(nbr_l)
TextWindow.Pause()
For i= 0 To 1
  nbr[i+nbr_l] = fgd[i]
EndFor
TextWindow.writeline(nbr)
Program.delay(1000)
Goto start


5). Multi dimension array question. Look at for the code below, do you think the code will generated y as a multi dimension array? or not?

x[0] = 10
x[1] = 11

For i = 0 To 1
  y[i] = x
EndFor


TextWindow.WriteLine(y)
 

6). Still based on question 5, how many lines or rows, array y have?

Tidak ada komentar:

Posting Komentar