Question: Hello, guys, I got stuck on this problem. The program below is fully functional but now I wanted to add another function where I can
Hello, guys, I got stuck on this problem. The program below is fully functional but now I wanted to add another function where I can search and output for the location of the number that user input and so how can we do that. Would much appreciate for fully slightly modified program base on mine, thank you so much for helping.
#include
using namespace std;
void fillArray(int a[][5], int size);
void printArray(int a[][5], int size);
int countNums(int ar[][5], int size, int search);
int main()
{
int ar[5][5];
fillArray(ar, 5);
printArray(ar, 5);
cout
int num;
cin >> num;
int count = countNums(ar, 5, num);
cout
return 0;
}
void fillArray(int a[][5], int size)
{
for (int row = 0; row
{
for (int col = 0; col
{
a[row][col] = rand() % 10 + 1;
}
}
}
void printArray(int a[][5], int size)
{
for (int row = 0; row
{
for (int col = 0; col
{
cout
}
cout
}
}
int countNums(int ar[][5], int size, int search)
{
int count = 0;
for (int row = 0; row
{
for (int col = 0; col
{
if (ar[row][col] == search)
count++;
}
}
return count;
}


#include using namespace std; void fil1Array(int a[][5], int size); void printArray(int a[][5], int size); int countNums (int ar[][5], int size, int search); int mainO 7 int ar[5]05] fillArray(ar, 5); printArray (ar, 5); 10 14 15 16 17 cout "What number do you want to search for? " endl; int num; cin > num; int count -countNums (ar, 5, num); 19 20 cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
