C++ Program to Print Full Number Pyramid

In this program, you'll learn to print full number pyramid.



Source Code

#include<iostream>
using namespace std;

int main()
{
    int i, j, s, k;

    for(i=0; i<4; i++)
    {
        for(s=0; s<3-i; s++)
        {
            cout<< "  ";
        }
        for(j=0;j<=i; j++)
        {
            cout<< j+1 << " ";
        }
        for(k=j-1;k>0; k--)
        {
            cout<< k << " ";
        }
        cout<< "\n";
    }
    return 0;
}
Output
      1
    1 2 1
  1 2 3 2 1
1 2 3 4 3 2 1





"Coding Hub - Learn to code" app now available on Google Play Store