This program demonstrates array processing, including: display, total, max, min, parallel arrays, sort, fixed arrays, dynamic arrays, and multidimensional arrays.
Main Program
Create name and age arrays
Display arrays
Calculate sum of ages
Calculate maximum age
Calculate minimum age
Display sum, maximum, and minimum
Sort and display ages
Display parallel arrays
Demonstrate fixed array
Demonstrate dynamic array
Demonstrate multidimensional array
Calculate Sum
Parameters:
Array
Process:
Initialize total
Loop for index from 0 to array length by 1
Add array index value to total
Return Value:
Sum
Calculate Maximum
Parameters:
Array
Process:
Initialize maximum to first array value
Loop for index from 1 to array length by 1
If maximum < array index value
maximum = array index value
Return Value:
Maximum
Calculate Minimum
Parameters:
Array
Process:
Initialize minimum to first array value
Loop for index from 1 to array length by 1
If minimum > array index value
minimum = array index value
Return Value:
Minimum
Demonstrate Parallel Arrays
Parameters:
Name Array
Age Array
Process:
Loop for index from 0 to array length by 1
Display array index name and age
Return Value:
None
Demonstrate Fixed Array
Parameters:
None
Process:
Initialize array with 5 null values
For index from 0 to array length by 1
Set array index value to a random number
Display array
Return Value:
None
Demonstrate Dynamic Array
Parameters:
None
Process:
Initialize empty array
For index from 0 to 5 by 1
Append a random number to the array
Display array
Return Value:
None
Demonstrate Multidimensional Array
Parameters:
None
Process:
Initialize multidimensional array as a tic-tac-toe game
For row from 0 to 2 by 1
For column from 0 to 2 by 1
Display array element
If column < 2
Display separator
Go to next output line
Return Value:
None