Q:

Java program to print the following pattern on the console

belongs to collection: Java Pattern programs

0

Algorithm:

  • STEP 1: START
  • STEP 2: SET size=6.
  • STEP 3: SET i=size. REEPAT STEP 4 to STEP 9 UNTIL i!=0
  • STEP 4: SET j=0.REPEAT STEP 5 UNTIL j<(size-i).
  • STEP 5: PRINT "" and SET j=j+1
  • STEP 6: SET k = 0. REPEAT STEP 7 UNTIL k<(2*i-1)
  • STEP 7: PRINT * and SET k=k+1
  • STEP 8: PRINT new line.
  • STEP 9: SET i=i-1.
  • STEP 10: END

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

public class pattern    
    
   public static void main(String[] args)     
   {    
       int size ;    
       size =6;    
       for (int i = size; i != 0; i--)     
       {    
           for (int j = 0; j<size-i; j++)    
           {    
               System.out.print(" ");    
           }    
           for (int k = 0; k < (2 * i - 1); k++)     
           {    
               System.out.print("*");    
           }    
           System.out.println();    
   }    
   }    

Output:

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java program to print the following pattern on the... >>
<< Java program to print the following pattern on the...