that returns a triangular array containing the values of Pascal's triangle.
For example if rows is 6 then pascal will return the following ragged array
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 2 3 4 5 6 7 8 9 10 11 12 13
int ** pascal(int rows){
**p = newint (rows);
temp = *p
int x=1;
cin>>rows;
for(int i=0;i<=rows;i++){
for(int k=0;k<=i;k++){
cout << x << " ";
x = x * (i - k) / (k + 1);
}
cout << endl;
}
}
Remarks:
⇒ When executed, your code modified memory in a way that was illegal. Common causes for this problem include array indexing errors and pointer operation (*) errors.
More Hints:
⇒ You almost certainly should be using: new
⇒ You almost certainly should be using: temp
⇒ I haven't yet seen a correct solution that uses: /