Introduction to Arrays

Today’s lesson introduced 1-D arrays. The class started off by creating 3 programs.
1. Create a program to take in 3 numbers and display the sum and average.
2. modify the program to work with 5 numbers.
3. Modify the program to display the numbers after it displays the sum and average.

The class were given the main steps and asked to refine it, before starting the task. Each task was to be saved in separate folders.

The class was then asked to modify the program for 100 numbers. This led to discussion about the need for a new data type that could store a list of values, this data type is called Array.

Scratch was used to show how arrays can be used. The class then looked at the DIM command’s help page to discover how to set up an Array.

DIM IntNumber(50) as Integer

Where (50) is the number of items in the array.

The program was modified to allow entry of 100 values before the period finished.

HOMEWORK

Write the refinements for the main program given for 100 numbers.

  1. Set up Variables
  2. Get 100 values from user
  3. Calculate Average and Sum of values
  4. Display the Average, Sum and values
  5. End program