Help with Displaying an array (updated)

I am having problems trying to display the code. It is for part of my homework. I will give the link to the problem and the problem demmo and see if someone can help me. I've looked everywhere for help on this one and couldn't find it. On page 22 or 134 Lab 7.4 option 1 is where I am at. The Link is here http://www.harding.edu/ragsdale/comp151/lm_chapter%2007.pdf


This is what I have so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>

using namespace std;


const int   MAX_TOTAL_AGES = 100;
typedef int ageType[MAX_TOTAL_AGES];



void finalData ( const ageType, int );


int main ()
{

ageType age;
int pos =0;
int numberOfAges;


cout << "Please input an age from one to 100, put -99 to stop ";
    cin >> age[pos];

do
{
    pos++;

    cout << "Please input an age from one to 100, put -99 to stop ";
    cin >> age[pos];
}while (age[pos] != -99);

numberOfAges = pos;
finalData(age,numberOfAges);


return 0;
}



void finalData ( const ageType array ,  int size )
{
    static int num = array[0];
    int tot = 0;
        int counter = 0;


    for (int i = 0; i < size; i++ )
    {
        for (int j = 0; j < size; j++)
        {
            if(array[i] == array[j])
            {
                counter++;
                cout << "The number of people " << array[i] << " years old is " << counter << endl;
            }
            counter = 0;
        }


    }

}

Last edited on
Topic archived. No new replies allowed.