Hi, I’m trying to build the table below.
—————————————————————————
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
——————————————————————————–
Can you fill in the code to build the table? Here is the file below.
——————————————————————————-
// app.cpp
#include <iostream>
#include <iomanip> // Use setw() for proper column output. I used 3.
using namespace std;
const int ROWS = 10;
const int COLS = 15;
int main()
{
int ** table; // This is a pointer to a pointer. Use it to create
// a two-dimensional array.
// Write code here to allocate memory for the table
// Step 1: Allocate an array of pointers that has ROWS elements.
// Step 2: Allocate each row to have COLS elements.
// Write code here to populate it with required integers
// as per the lab assignment document.
// Write code here to print the table.
// Write code here to deallocate memory for the table.
// You allocated each row, so now you have to deallocate each row.
// Then deallocate the table pointer itself.
// Run this program in valgrind to make sure there are no leaks.
// Valgrind command: valgrind –leak-check=full ./lab5app
return 0;
}