CODING JOY

The stunning potpourri of coding and mundane life

SPLIT PYRAMID PATTERN IN JAVA



AMRUHA AHMED
11th October,2023.



This article will aid you in the creation of a split pyramid pattern in Java using a combination of nested loops.

blog1

DELVING DEEPER:

BREAK-UP OF THE PATTERN:

blog1

PROGRAM:

                
class splitpyramid
{
    void main()
    {
         int s=7;//number of spaces to be printed
         int i,j;//loop counters
         for(i=1;i<=7;i++)
         {
             for(j=1;j<=s;j++)
             {
                 System.out.print("  ");
             }
             for(j=1;j<=i;j++)
             {
                 System.out.print("* ");
             }
             System.out.print(" ");
             for(j=1;j<=i;j++)
             {
                 System.out.print("* ");
             }
             System.out.println();
             s--;
           }
    }
}
             
         
CODE COPIED

OUTPUT:

blog1