Create a file called lab8.cpp and declare a static 2D array inside main() to store the number of people living in each house in a city block. The houses are laid out in a 4x3 grid.
a. Example from TA demo (you will need to change this):
int house_population[4][3];
2. Write a nested for loop to set the number of people living in each house to a random number between 1 and 10.
a. Remember to seed the random number generator once at the start of main().
b. Example from TA demo (you will need to change this):
for (int x = 0; x < 4; x++)
for (int y = 0; y < 3; y++)
house_population[x][y] = rand()%10 + 1; /* 1-10 people */
3. Write a nested for loop to print out the populations that were generated, showing the coordinates of each house and the number of people in the house.
(2 pts) B. Dynamic 2D Arrays
1. Add code to read in two numbers from the user to define the layout of a new city block.
2. Declare a dynamic 2D array inside main() to store the number of people in this new city block.
a. Example from TA demo (you will need to change this):
int** city_block = new int*[size_x];
for (int x = 0; x < size_x; x++)
city_block[x] = new int[size_y];
3. Write a nested for loop to set the number of people living in each house to a random number between 1 and 10.
4. Write a nested for loop to print out the populations that were generated, showing the coordinates of each house and the number of people in the house.
5. Use valgrind to check your program for memory leaks.