< previous page page_628 next page >

Page 628
Statement
Character
index
found
freqList
Priming read
R
?
?
1.1
R
?
FALSE
2.1
R
?
FALSE
3.1
o
?
FALSE
1.2
o
3
TRUE
2.2
o
3
TRUE
freqList[3] is 1
3.2
s
3
TRUE
1.3
s
?
FALSE
2.3
s
?
FALSE
3.3
e
?
FALSE
1.4
e
1
TRUE
2.4
e
1
TRUE
freqList[1] is 1
.
.
.
3.8
e
?
FALSE
1.9
e
1
TRUE
2.9
e
1
TRUE
freqList[1] is 2

The output from the program using this data would be as follows:
a occurred 5 time(s)
e occurred 7 time(s)
i occurred 1 time(s)
o occurred 4 time(s)
u occurred 2 time(s)
At first glance, the output does not seem right. If you count the characters by hand, you come up with three occurrences of 'i'. Note, however, that two of these are of 'I', not 'i'. If we want to count uppercase letters and lowercase letters as the same, we have to convert one of them (using, for example, the tolower or toupper standard library functions).
Testing: The test data for this program should include cases in which (1) there are no characters to be counted and (2) there is no text to count.

 
< previous page page_628 next page >