The following program counts the number of times a particular letter, aChar, appears in a string. It is another example of the accumulator pattern that we have seen in previous chapters.
The function count takes a string as its parameter. The for statement iterates through each character in the string and checks to see if the character is equal to the value of aChar. If so, the counting variable, lettercount, is incremented by one. When all characters have been processed, the lettercount is returned.