So im doing an assignment for class and im not sure what/how to proceed, im struggling with storing randomly generated numbers in an array and then calling on them later to display how many times the random number has been called them. as you might notice i already have my first array and is used to display 100 random numbers between 0 through 9. been stuck for a while now and am finally at the point where i need some help on understanding where/what to do from here.

just a heads up i am still very new to c++ so forgive my unorganization, i have yet to set up my void function above the int main.

#include <iostream>
using namespace std;


int main()
{
    int randomnumber[100], storenumber[10] = {0,0,0,0,0,0,0,0,0,0};

    for (int i = 0; i < 100; i++ )
        {
            randomnumber[i] = rand()%10;

        }


            system("PAUSE");
    return 0;
}

 void count (int &x, int &n)
{ 
        x = [0];
        storenumber[1] = ;
        storenumber[2] = ;
        storenumber[3] = ;
        storenumber[4] = ;
        storenumber[5] = ;
        storenumber[6] = ;
        storenumber[7] = ;
        storenumber[8] = ;
        storenumber[9] = ;
}

I think that you need another for loop inside the count function, which will go over the array of random numbers and count each value. You should also use more descriptive names for the arguments to the count function; so x and n should be something more like values and frequencies, or something like that. That would make the signature to your count function look more like:

void count( const int* values, int valueCount, int* frequencies );

Notice that I have included a valueCount variable in the signature, since you're going to want to know how many values are in the values array :)

Thank you for the help. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.