× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You don't actually need an array with overlays or parallel arrays for this.
Use the age as the index and put a counter in each cell.  When you print the
results, don't print the cells whose value is zero.
An array with 100 cells--200 to be real safe--should do the trick.

In pseudocode--

first get the ages and count them

while more employees
array(age) = array(age) + 1

then print them

for i = 1 to arraysize
        if array(i) <> 0
        print i, array(i)



> -----Original Message-----
> From: Wills, Mike N. (TC) [mailto:MNWills@taylorcorp.com]
> Sent: Thursday, September 06, 2001 3:06 PM
> To: 'RPG400-L@midrange.com'
> Subject: Array help
>
>
> Okay, for some reason I can't remember how to do this. I need
> to count the
> number of people for each age that work within the company
> (for demographics
> stuff). The problem is that I forgot how to deal with multiple arrays.
>
> The way I am doing this (...and I am open to better ways) is
> to create a
> multi-column array that holds the age and the count. When I process an
> employee, I will lookup to see if the age is in the array. If
> it is, I add 1
> to my counter. If not, I add the age in to my array. But, I
> would like it in
> numeric order so when I go to print it out, it is in age order.
>
> I guess what I would like to know what the best approach to
> this would be. I
> haven't dealt with arrays for a while again. Is my idea a
> good approach for
> this? How do I create a 2-column array? Example:
>
> Ages  AgeCount
> 21    5
> 35    6
> 18    1
> 20    10
> 45    50
>
> Thanks for any help given....
>
> Mike Wills
> _______________________________________________


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.