C++ Programming Code Examples C++ > Pyramid Patterns Code Examples C++ Program for Print Pascal Triangle Pattern C++ Program for Print Pascal Triangle Pattern Pascal's triangle is a triangular array of the binomial coefficients. The rows of Pascal's triangle are conventionally enumerated starting with row n = 0 at the top (the 0th row). The entries in each row are numbered from the left beginning with k = 0 and are usually staggered relative to the numbers in the adjacent rows. Having the indices of both rows and columns start at zero makes it possible to state that the binomial coefficient appears in the nth row and kth column of Pascal's triangle. /* Basic Pattern C++ Programs, Inverted Pascal Pattern C++ Programming*/ // Header Files #include <iostream> #include<conio.h> using namespace std; long factorial(int); int main() { int numberOfRows, i, j; cout << "Simple C++ Program for Print Pascal Triangle Pattern\n"; cout << "Happy Codings - Programming Code Examples"; //Read Day Value cout << "Enter the number of rows to be printed in your pascal triangle : "; cin>>numberOfRows; for (i = 0; i < numberOfRows; i++) { for (j = 0; j <= (numberOfRows - i - 2); j++) cout << " "; for (j = 0; j <= i; j++) cout << " " << factorial(i) / (factorial(j) * factorial(i - j)) << " "; cout << "\n"; } getch(); return 0; } long factorial(int n) { int c; long result = 1; for (c = 1; c <= n; c++) result = result * c; return result; }