A Pascal triangle pattern program in c++. Using this program we can print the pascal pattern program using for loop. Pascal’s Triangle is a numerical pattern with a triangle shape. It is named after the French mathematician Blaise Pascal. Pascal’s Triangle is used in mathematics and statistics for a variety of purposes, including assisting in the calculation of combinations.
using namespace std;
int n, k = 0;
cout<<"Enter the number of rows";
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n - i; ++j)
while (k != 2 * i - 1)
Enter the number of rows 3
* * *
* * * * *
How to execute the pascal triangle pattern program in c++
We’ll use three loops to print the Pascal’s triangle: two for loops and one while loop. The number of rows is printed using the first loop. The spaces between the stars are printed using the second loop. The stars are printed using the third loop, the while loop.
What is for loop in c++ program
A for loop is a repetition control structure that lets you design a loop that needs to run a certain number of times quickly.
What is while loop in c++ program
A while loop is a control flow statement that runs a block of code at least once before deciding whether or not to run it again based on a boolean condition at the conclusion of the block.