Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arrays Part 2.

Similar presentations


Presentation on theme: "Arrays Part 2."— Presentation transcript:

1 Arrays Part 2

2 Objectives Search a one-dimensional array
Compute the average of a one-dimensional array’s contents Find the highest entry in a one-dimensional array Update the contents of a one-dimensional array Sort a one-dimensional array

3 Manipulating One-Dimensional Arrays
Array elements can be used like any other variable Examples: Display the contents of an array Access an array element using its subscript Search the array Calculate the average of data stored in a numeric array Find the highest value stored in an array Update array elements Sort array elements

4 The For Each…Next Statement
Used to code a loop which processes each element in a group or array Creates a variable used to represent each item in the group or array Data type of the element must match the data type of the group Syntax: For each element [as datatype} in group Statement(s) Next

5 The For Each…Next Statement (cont’d)
Hands-on Example

6 Searching a One-Dimensional Array
Hands-on Example

7 Calculating the Average Amount Stored in a One-Dimensional Numeric Array
Sample application: Find the average from an array of test scores Length property: number of elements in the array

8 Determining the Highest Value Stored in a One-Dimensional Array
Hands-on Example

9 Updating the Values Stored in a One-Dimensional Array
Hands-on Example

10 Sorting the Data Stored in a One-Dimensional Array
Sorting: arranging data in a specific order Ascending: first element is smallest, last element is largest Descending: first element is largest, last element is smallest Array.Sort method: used to sort elements in a one-dimensional array in ascending order Array.Reverse method: used after Array.Sort method to change to descending order

11 Sorting the Data Stored in a One-Dimensional Array (con’d)
Hands-on Example


Download ppt "Arrays Part 2."

Similar presentations


Ads by Google