RheighHenleyCalderon
2,295 views
17 slides
Mar 20, 2012
Slide 1 of 17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
About This Presentation
No description available for this slideshow.
Size: 1.72 MB
Language: en
Added: Mar 20, 2012
Slides: 17 pages
Slide Content
% Often advantageous for a user to store several
values for the same variable in the internal
memory of the computer because it decrease:
processing time.
% This multiple storage means there has to bel
more than one memory location in the|
computer for each variable name.
% When more than one memory location ¡sf
designated for a single variable, it is called
an array.
$ When using dynamic arrays, the programmer
designates the number of array locations as
variable, which can be expanded or contract ed!
during the execution of the solution.
% Because computers are zero-based, for
counting purposes, many programming]
languages are also zero-based.
Variable
Reference
Name
AGE(1)
AGE(2)
AGE(3)
AGE(4)
AGE(6)
AGE(7)
AGE(8)
AGE(S)
The number in the
parentheses refers
tothe box number
in the array, the
‘element number.
9
3
E
&
Algorithm Flowchart
LOOP:R = 1 TO N STEP
[extn ao
LOOP-END:R
1h ¿Ri="0)
2. REPEAT
R = R+1
ENTER A(R)
UNTIL A(R) =
*3. N= R-1
-R=1
. ENTER A(R)
. WHILE A(R) <>
R= RH
ENTER A(R)
WHILE — END
LOOP: R=1 TO N STEP 1
[Erınr A(R)
LOOP-END: R
R= Bement number
LOOP:R = 1 TO N STEP 1
[Sum = sum + am)
LOOP-END: R
Number of elements
lement number
Sum of the
elements of A
Rh element of the
locations associated with a single memory variable|
name and designated by row and column numbers.
You load a two-
dimensional array
with nested loops.
The data are
normally loaded
row by row. When|
you load the data
row by row, the|
outer loop
representsthe row,
and the inner loop
represents the
column
E
LOOP:R = 1 TO NR STEP 1
LOOP: C = 1 TO NC STEP 1
JA(R,NC + 1,
+ A(R,C)
JA(NR + 1,0)
+ A(R,C)
A(R,NC + 1)
A(NR + 1,C
LOOP-END: C
A(NR + 1,NC + 1) =
A(NR + 1, NC + 1
+A(R, NC + 1)
In some cases there is a need for arrays with a third or|
leven a fourth dimension. These arrays are called]
multidimensional arrays.
Advanta
# Facilitate an
understanding
of the data
# Improve the
readability of
value in a table. A one-dimensional array would be used if the]
element number can be utilized as the given value. A two-
dimensional array with two columns would be used if the element
number cannot be utilized.