Print Full Pyramid Pattern of Numbers in C++

This article will teach you how to Print Full Pyramid Pattern of Numbers in C++.

How to Print Full Pyramid Pattern of Numbers in C++ language.

Desired Output for Size 5:
1
121
12321
1234321
123454321
#include <iostream>
using namespace std;
int main()
{
   int num, a;

   cout<<"Please enter the number of rows: ";
   cin>>num;

   for(int r=1; r<=n; r++)
   {
     for(int c=1; c<=n-r; c++) 
           cout<<" ";

     for(int k=1;k<=(2*r-1);k++)
     {
       if(k<r) 
          cout<<k;
       else if(k==r)
       {
         cout<<k;
         a=k;
       }
       else 
         cout<<--a;
     }

     cout<<"\n";
   }

   return 0;
}

Output