### A Brief Introduction to Arrays

Last week, you learned that selection of one of several actions can be accomplished by a "cascaded conditional" statement, and saw some examples. Here is another example: determine a student's final class letter grade from the percentage grade. In rather compact pseudocode:

End If

That's fine for one student.  But there are 32 students in this class.  If I have variables numericGrade1 and letterGrade1 for student 1, numericGrade2 and letterGrade2 for student 2, etc., then to compute all the grades I would have to write

End If

End If

Etc., etc., ...

End If

That's 140 lines of code.  There has got to be a better way!

For (count = 1; count <= 32; count = count + 1)
End If
End For

What we have here is two arrays.  An array is a group of several variables of the same type, of some specific size. An array is given a variable name, like numericGrade, and the specific item in the group is referred to by the array name, followed by an integer value in square brackets.

Of course, arrays have to be declared, just like any other variable. When you declare an array, you have to give it an name and a data type (just like an ordinary variable), and you also have to specify the size of the array.  The declarations appropriate to the above situation are