Exercise 4: Pascal Triangle

Let's create a function that displays the Pascal Triangle for any given size.

Problem Statement

In this exercise, you’re given the printPascalTr(int size) function. It takes the given size and display a table that represents the corresponding Pascal 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.

By signing up, you agree to Educative's Terms of Service and Privacy Policy