Using the following pseudocode write a function that creates a 2-dmatrix represe
ID: 3619128 • Letter: U
Question
Using the following pseudocode write a function that creates a 2-dmatrix representing the Pascal triangle:Algorithm PascalTriangle
pascal[0][0] = 1
pascal[1][0] = 1
pascal[1][1] = 1
prevRow = 1
currRow = 2
while( currRow <= 5 )
pascal[row][0] = 1
col =1
while(col <= currRow )
pascal[row][col] = pascal[row - 1][col - 1] + pascal[row -1][col]
col = col + 1
end loop
endloop
end PascalTriangle
An Example of a Pascal triangle of size 7:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
Thank you!
Explanation / Answer
please rate - thanks #include #include int main() { int pascal[10][10],prevRow,currRow,col,i,j,n; printf("Enter size of triangle: "); scanf("%d",&n); pascal[0][0] = 1; pascal[1][0] = 1; pascal[1][1] = 1; prevRow = 1; currRow = 2; while( currRowRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.