C++ Triangle pattern

PROGRAM CODE :

 #include<iostream.h>  
 #include<conio.h>  
 void main()  
 {  
          char a[]="program";  
          int i,j;  
          clrscr();  
          for(i=0;i<7;i++)  
          {  
                   for(j=0;j<=i;j++)  
                   {  
                           cout<<a[j]<<'\t';  
                   }  
                   cout<<endl;  
           }  
           getch();  
 }  

OUTPUT :

   p
   p    r 
   p    r    o 
   p    r    o    g 
   p    r    o    g    r 
   p    r    o    g    r    a
   p    r    o    g    r    a    m

Comments

Popular posts from this blog

Library Management System ( CPP coding ) :

C++ Hourglass pattern

Insert a node into a sorted doubly linked list Solution