Back

Pattern 26

C
            #include<stdio.h>
              #include<conio.h>
              void main(){
                int i, j;
                clrscr();
                for(i=5;i>0;i--){
                   printf("\n");
                   for(j=5;j>i;j--){
                printf("  ");
                   }
                   for(j=i;j>0;j--){
                printf(" %d  ", j);
                   }
                }
                getch();
             }
          
Output:
            5   4   3   2   1
              4   3   2   1 
                3   2   1
                  2   1
                    1
          
Download Program
Java
            public class Pgm26 {
              public static void main(String[] args) {
                // TODO Auto-generated method stub
                for(int i=5;i>0;i--){
                      System.out.print("\n");
                      for(int j=5;j>i;j--){
                  System.out.print("  ");
                      }
                      for(int j=i;j>0;j--){
                  System.out.print(" "+j+"  ");
                      }
                  }
              }
            }
          
Output:
            5   4   3   2   1
              4   3   2   1 
                3   2   1
                  2   1
                    1
          
Download Program
C++
            #include<iostream>
            using namespace std;
            int main(){
              int i, j;
              for(i=5;i>0;i--){
               cout<"\n";
               for(j=5;j>i;j--){
                 cout<<"  ";
               }
               for(j=i;j>0;j--){
                 cout<<" "<<j<<"  ";
               }
             }
             getc;
             return 0;
           }
          
Output:
            5   4   3   2   1
              4   3   2   1 
                3   2   1
                  2   1
                    1
          
Download Program