PROGRAM TO PRINT A PATTERN – 2

/*PROGRAM TO PRINT A PATTERN – 2*/

#include<conio.h>

#include<iostream.h>

class pattern

{

int i,j,n,count,k,l;

public:

void process();

};

void pattern::process()

{

cout<<“Enter the limit of rows: “;

cin>>n;

count=0;

for(i=1;i<=n;i++)

{

for(l=1;l<=n-i;l++)

cout<<” “;

for(j=i;j<=count+i;j++)

cout<<j;

for(k=count+i-1;k>=i;k–)

cout<<k;

cout<<endl;

count++;

}

}

void main()

{

pattern p1;

clrscr();

p1.process();

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *