teach-ict.com logo

THE education site for computer science and ICT

Answer: Question 14


The correct answer is:

   array even_array []   # declare the array
   x = 0  # array  index counter
   FOR p ← 0 to 100
   
      IF p MOD 2 =  0   # check for an even number
           even_array[x] ← p  #  store the number
           INCREMENT x  # point to the next position in  the array
      ENDIF
    ENDFOR
   
# Now print out the result
   array_length ← LEN(even_array) - 1
   FOR p ← 0 to array_length
       OUTPUT even_array[y]
   ENDFOR