### 2 dimensionals

This program is supposed to output the row and column of the number entered by the user but it is not working that way and honestly i am confused on how to do it.. Help!!

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364`` ``````#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]; int row = 0; int col = 0; fillArray(ar, 5); printArray(ar, 5); cout << "What number do you want to search for? " << endl; int num; cin >> num; countNums(ar, col, row); cout << "Your number appears " << row << col << " in the array." << endl; return 0; } void fillArray(int a[][5], int size) { for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) { a[row][col] = rand() % 10 + 1; } } } void printArray(int a[][5], int size) { for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) { cout << a[row][col] << "\t"; } cout << endl; } } int countNums(int ar[][5], int size, int search) { int row = 0; int col = 0; for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) { if (ar[row][col] == search) row++; col++; } } return row, col; }``````
Last edited on
Why are you incrementing row after a match has been found?
Topic archived. No new replies allowed.