Exercise 4: Pascal’s Triangle
Create a function that displays the Pascal’s triangle for any given size.
We'll cover the following
Problem statement
Display Pascal’s triangle for the specified size. You’re given the printPascalTr(int size)
function. It takes the given size and displays a table that represents the corresponding Pascal’s triangle.
In Pascal’s triangle:
The first and the second rows are set to
1
.Each element of the triangle (from the third row downward) is the sum of the element directly above it and the element to the left of the element directly above it.
Sample input
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy