hw assignment asks 4 the construction of a 2d array with the generation of random numbers 1-10 which has been done.

next ask the user 4 which numbers occurence in the array he wants to find and its location.

i have come up with this so far but the occurence part does not work right. need some plz.

thanks

```
#include <iostream>
#include <ctime>
using namespace std;
void fillar(int ar[][9], int numRows);
void printar(const int ar[][9], int numRows);
int howmanyar(int x , const int ar[][9], int numRows);
int main()
{
int userinput;
srand(time(0));
int ar[10][9];
fillar(ar, 10);
printar(ar, 10);
cout<<"Enter the number whose occurence and location you want to find from the table:"<<endl;
cin>>userinput;
int x = howmanyar(userinput, ar, 10);
cout<<"The number has an occurence of "<<x<<endl;
return 0;
}
void fillar(int ar[][9], int numRows)
{
for(int row = 0; row < numRows; row++)
{
for(int col = 0; col < 9; col++)
{
ar[row][col] = (rand() % 10) +1;
}
}
}
void printar(const int ar[][9], int numRows)
{
for(int row = 0; row < numRows; row++)
{
for(int col = 0; col < 9; col++)
{
cout << ar[row][col] << "\t";
}
cout<<endl;
}
}
int howmanyar(int x , const int ar[][9], int numRows)
{
int a = 0;
for (int i = 0; i < numRows; i++)
{
if(ar[i][i] == x)
a++;
}
return a;
}
```