Question: C++ code Implement a function called pascal that returns a dynamically allocated two-dimensional array that represents the rows of Pascal's triangle. That means the first

C++ code Implement a function called pascal that returns a dynamically allocated two-dimensional array that represents the rows of Pascal's triangle. That means the first row will have length 1 and contain a single 1. The second row will have length 2 and contain two 1's. The third row will have length 3 and contain the three values 1, 2, 1. In general, the row at index i will have length i+1 and values filled in as follows: The first and last elements in the row are equal to 1 and for each index j in the range {1, ..., i-1} the element at that index will be the sum of the elements at indexes j-1 and j from the previous row. See the picture below to see how that works.

C++ code Implement a function called pascal that returns a dynamically allocated

The prototype for pascal is int ** pascal(int n); , n is the total number of rows, e.g. for the pic above n would be 8 since there are eight rows.

Use dynamic allocation except this time the rows will all have different lengths.

To test code with:

#include  void printPascal(int ** array, int n) {  for (int i = 0; i   for (int j = 0; j   cout   for (int j = 0; j   cout   cout   } }

Result of output of printPascal when passed an array obtained from a call to pascal(10) and second parameter 10 should look like this:

two-dimensional array that represents the rows of Pascal's triangle. That means the

Please provide code for whole program and function itself.

111121133114641151010511615201561172135352171 1

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!