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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started