Skip to main content

Featured

functions in Python

C++ program to print the following pattern of hollow triangle


/*program to print the following pattern of hollow triangle
            &
         &   &
       &       &
     &            &
    &               &
 &&&&&&&&&&
*/  
#include<iostream.h>
#include<conio.h>
void main(void)
{
   clrscr();
   int i,j,k,l,spo=5,spi=-1;
   for(i=1;i<=6;i++,spo--,spi+=2)
   {
    for(l=1;l<=spo;l++)
    {cout<<" ";}
    cout<<"&";
    for(l=1;l<=spi;l++)
    {cout<<" ";}
    if(i==2||i==3||i==4||i==5)
    cout<<"&";
    if(i==6)
    {cout<<"\r";
    for(l=1;l<=11;l++)
    cout<<"&";
    }
   cout<<"\n";
   }
   getch();
}

Comments

Popular Posts