counting values in array

I have to write a program that generates 100 random integers between 0 and 9 stored into an array. Pass the array 10 different times to a function that traverses the array and counts how many times a particular value occurs in the array. I have no problem generating the array or passing it to the function; however, I'm stumped on the function that counts the particular values. Also, I have to use a for loop in the count function. Any help would be appreciated.
You just need a count++ in the body of the loop.
Post your code and show us where youre at and someone will help
What I'm having problems understanding is how to only count certain values in function count. ie, first time count is invoked I want to return the value of how many zeros are in the array, second time count is invoked return the number of ones, etc.


#include <iostream>
#include <ctime>

#define size 100
using namespace std;

int count(int x[], int);

int main()
{
int x[size], //
i; //

srand(time(NULL));

for (i=0; i<size; ++i)
x[i]= rand() % 10;

for (i=0; i<10; ++i)
count(x,i);


system("PAUSE");
return 0;
}

int count(int x[], int i)
{

}
I figured out my problem. The program is now working, so no help is needed. Thanks.
Last edited on
Then you should mark this thread as solved.
Topic archived. No new replies allowed.