Print Pascal's triangle with numbers.
Real Life: Important mathematical triangle in combinatorics.
An integer n (number of rows).
Pascal’s Triangle printed up to n rows.
• n ≥ 1
• Use integers
• Use loops only
Pascal’s Triangle is a number pattern where:
• First and last number of every row is 1.
• Middle numbers are the sum of two numbers just above it.
It is widely used in combinations and probability.
1.Take input n.
2.Print rows from 0 to n-1.
3.For each row i:
• First and last value is 1.
4.For middle positions j:
• Value = previous row j-1 + previous row j.
• Formula:
C[i][j] = C[i-1][j-1] + C[i-1][j]
5.Print each row on a new line.