Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise 5.3 (15 points) Write an algorithm to generate Yang Hui Triangle, and p

ID: 3911557 • Letter: E

Question

Exercise 5.3 (15 points) Write an algorithm to generate Yang Hui Triangle, and print out the diagram as follows { tf1nsinsicpg1252 { onttbl 0 nil charset0 TimesNewRomanPSMT;} {colortbl; ed255green255lue255; ed0green0lue0;} {*expandedcolortbl;;cssrgbc0c0c0;} deftab720 pardpardeftab720 i440partightenfactor0
0 s36 cf0 expnd0expndtw0kerning0 outl0strokewidth0 strokec2 }
Exercise 5.3 (15 points) Write an algorithm to generate Yang Hui Triangle, and print out the diagram as follows { tf1nsinsicpg1252 { onttbl 0 nil charset0 TimesNewRomanPSMT;} {colortbl; ed255green255lue255; ed0green0lue0;} {*expandedcolortbl;;cssrgbc0c0c0;} deftab720 pardpardeftab720 i440partightenfactor0
0 s36 cf0 expnd0expndtw0kerning0 outl0strokewidth0 strokec2 }
Exercise 5.3 (15 points) Write an algorithm to generate Yang Hui Triangle, and print out the diagram as follows { tf1nsinsicpg1252 { onttbl 0 nil charset0 TimesNewRomanPSMT;} {colortbl; ed255green255lue255; ed0green0lue0;} {*expandedcolortbl;;cssrgbc0c0c0;} deftab720 pardpardeftab720 i440partightenfactor0
0 s36 cf0 expnd0expndtw0kerning0 outl0strokewidth0 strokec2 } { tf1nsinsicpg1252 { onttbl 0 nil charset0 TimesNewRomanPSMT;} {colortbl; ed255green255lue255; ed0green0lue0;} {*expandedcolortbl;;cssrgbc0c0c0;} deftab720 pardpardeftab720 i440partightenfactor0
0 s36 cf0 expnd0expndtw0kerning0 outl0strokewidth0 strokec2 }

Explanation / Answer

start.

1.first take input from a user which is the size or number of line in a triangle.

2. Declare a 2-D array of size equals to a line, let that be A[line][line].

3.Start a loop from i=0 index to i<line and print integer(s) inside it.

4. Start another loop inside above loop from j=0 to j<=i with incrementation of 1 only.

5. Assign first and last value in every row =0 and add the remaining according to yang hui rule, for which we have to check the condition

if(i==j) or if(j==0)

assign 1 to A[i][j] .

else

A[i][j]=A[i-1][j-1]+A[i-1][j].

6. within these loops and after if condition print A[i][j] index element.

7. change the line after j-th loop and then close i-th loop.

8.stop.

Note.your question image is not clear.I hope you got your algorithm.In case you need to print anything else than you need to change only array values