C++ Program to Print Left Pascals Number Triangle

Write a C++ program to print the left pascals number triangle using for loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, k, rows;
     
    cout << "Enter Left Pascal Number Triangle Row = ";
    cin >> rows;

    cout << "Left Pascals Number Triangle Pattern\n"; 

    for(i = 1; i <= rows; i++)
    {
    	for(j = i; j < rows; j++)
		{
            cout << "  ";
        }
        for(k = 1; k <= i; k++)
        {
            cout << k << " ";
        }
        cout << "\n";
    }	

    for(i = rows; i >= 1; i--)
    {
    	for(j = i; j <= rows; j++)
		{
            cout << "  ";
        }
        for(k = 1; k < i; k++)
        {
            cout << k << " ";
        }
        cout << "\n";
    }
	
 	return 0;
}
C++ Program to Print Left Pascals Number Triangle

This C++ example prints the left pascals triangle of numbers using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, k, rows;
     
    cout << "Enter Left Pascal Number Triangle Row = ";
    cin >> rows;

    cout << "Left Pascals Number Triangle Pattern\n"; 

    i = 1; 
    while(i <= rows)
    {
        j = i;
    	while(j < rows)
		{
            cout << "  ";
            j++;
        }
        k = 1;
        while( k <= i)
        {
            cout << k << " ";
            k++;
        }
        cout << "\n";
        i++;
    }	

    i = rows;
    while( i >= 1)
    {
        j = i;
    	while( j <= rows)
		{
            cout << "  ";
            j++;
        }
        k = 1;
        while(k < i)
        {
            cout << k << " ";
            k++;
        }
        cout << "\n";
        i--;
    }
	
 	return 0;
}
Enter Left Pascal Number Triangle Row = 9
Left Pascals Number Triangle Pattern
                1 
              1 2 
            1 2 3 
          1 2 3 4 
        1 2 3 4 5 
      1 2 3 4 5 6 
    1 2 3 4 5 6 7 
  1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 9 
  1 2 3 4 5 6 7 8 
    1 2 3 4 5 6 7 
      1 2 3 4 5 6 
        1 2 3 4 5 
          1 2 3 4 
            1 2 3 
              1 2 
                1