Saturday, January 7, 2012

c++ program to generate reverse pyramid of digits


#include<iostream.h>
#include<conio.h>
class REVERSE
    {
    private:
    int n,i,j,k,s;
    public:
    void read();
    void call();
    };
void REVERSE::read()
  {
  cout<<"enter limit\n";
  cin>>n;
  }
void REVERSE::call()
  {
  s=n;
  for(i=1;i<=n;i++)
  {
  for(k=s;k<=n;k++)
  {
  cout<<" ";
  }
  k=1;
  for(j=1;j<=s;j++)
  {
  cout<<k++<<"  ";
  }
  cout<<"\n";
  s=s-1;
  }
  }
void main()
{
REVERSE a;
clrscr();
a.read();
a.call();
getch();
}


No comments:

Post a Comment