I need to create A program That makes a 12x10 Array Grid Filled With Random Numbers From 0-99.
Then I need To Allow The User To Input A Number Between 0-99 And Then The program will then search through the array and count how many of the users number there is inside the array.
I need Help With The Last part As I Do Not Know How To Start It.. Please Help!
//Assignment 20 Program 3
#include <iostream>
#include <time.h> //included for srand(time(NULL))
usingnamespace std;
int main()
{
int input;
int number;
int row = 0;
int col = 0;
int Array[12][10];
srand(time(NULL));
//PrintArray
for (row = 0; row < 12; row++)
{
for (col = 0; col < 10; col++)
{
{
Array[row][col] = rand() % (100 - 0) + 0;
}
cout << Array[row][col] << "\t";
}
cout << "" << endl << endl;
}
cout << "--------------------------------------------------------------------------------" << endl << endl;
cout << "Enter Number Between 0-99 To Search In The Array: ";
cin >> input;
cout << "" << endl;
//Search Array With Input
int Number_Of_Occurrences = 0; //Initialize number of occurrences for your # to be 0
for (int row = 0; row < 12; row++)
{
for (int column = 0; column < 10; column++)
{
if (Array[row][column] == input) //If the guessed number matches the cell being compared
{
Number_Of_Occurrences += 1; //Increment number of occurences by 1
}
}
}
cout << "Number of Occurrences: " << Number_Of_Occurrences << endl;
return 0;
}