- C++ program to find factorial using recursive function
- C++ program to convert binary number to decimal and decimal to binary
- C++ program to display prime numbers between two intervals
- C++ program to print Pascal’s and Floyd’s triangle
- C++ program to print star pyramid patterns
- C++ Hello World Program
- C++ program to display Fibonacci series using loop and recursion
- C++ program to find area of the circle
- C++ program to calculate the area of the square with and without using function
- C++ program to encrypt and decrypt the string
- C++ program to convert temperature
- C++ program to check prime number
- C++ program to check palindrome number
- C++ program to make simple calculator using switch case
- C++ program for time conversion (convert time format)
- C++ program to find GCD or HCF
- C++ program to check for the power of two
- C++ program to check Armstrong number
- C++ program to check leap year
- C++ program to find LCM of two numbers

In this example, you are going to learn about an easy **C++ program to print Pascal’s and Floyd’s triangle.**

It is a triangular array of the binomial coefficients which is named after French mathematician Blaise Pascal.

It is a right-angled triangular array of natural numbers which is named after Robert Floyd.

There are many ways to print Pascal triangle in C++ as well as Floyd triangle in C++.

```
//Pascal triangle in C++
#include <iostream>
using namespace std;
int main()
{
int n, i, j, c = 1, s;
cout << "Enter number of rows to print in Pascal triangle: ";
cin >> n;
//for loop continues till the number of rows entered by the user
for(i = 0; i < n; i++)
{
//for loop to print required number of space
for(s = 1; s <= n - i; s++)
cout << " ";
//for loop to print number in triangle
for(j = 0; j <= i; j++)
{
//first and last value of every row is 1
if (j==0 || i==0)
c = 1;
else
c = c *( i - j + 1) / j;
cout << c << " ";
}
cout << endl;
}
return 0;
}
```

**Output**

```
//Floyd's triangle in C++
#include <iostream>
using namespace std;
int main()
{
int r, i, j, num = 1;
//number of rows to print
cout << "Enter number of rows for Floyd's triangle: ";
cin >> r;
//for loop responsible for number of rows
for(i = 1; i <= r; i++)
{
//for loop responsible for number of columns
for(j=1; j <= i; ++j)
{
cout << num++ << " "; //print number starting from 1
}
//prints new number in next line
cout << endl;
}
return 0;
}
```

**Output**