My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to print double pyramid

Tuesday, September 1, 2009

#include<iostream.h>
 #include<conio.h>
 void main()
 {
  clrscr();
  for(int i=1;i<=5;i++)
  {
    for(int j=1;j<=5-i;j++)
    cout<<" ";
    cout<<"*";
    for(int k=1;k<=2*i-3;k++)
    cout<<" ";
    if(i!=1)
    cout<<"*";
    cout<<endl;
    }
   for(i=4;i>=1;i--)
   {
    for(int j=1;j<=5-i;j++)
    cout<<" ";
    cout<<"*";
    for(int k=1;k<=2*i-3;k++)
    cout<<" ";
    if(i!=1)
    cout<<"*";
    cout<<endl;
    }
    getch();
    }

0 comments: