Question: Find the problems with this program and its function #include #include // used to format output in neat columns using namespace std; // constants for

Find the problems with this program and its function

#include

#include // used to format output in neat columns

using namespace std;

// constants for array

const int ROW = 5;

const int COL = 5;

void showArray(int arr[][]);

int main() {

// define the array in main int arr[ROW][COL];

for(int i = 1; i <= ROW; i++) { for(int j = 1; j <= COL; j++) { arr[i][j] = 2 * i + j; } }

showArray(arr);

return 0; }

// function to display array, using setw to align columns void showArray(int arr[][COL]) { // loop to output the rows, one at a time for(int i = 0; i < ROW; i++) { // loop to output the values in that row for(int j = 0; j < COL; j++) { cout << setw(4) << arr[i][j]; }

// end this line of output cout << endl; }

// put final endline after table cout << endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!