Q:

Java program to print the following pattern on the console

belongs to collection: Java Pattern programs

0

Algorithm:

  • STEP 1: START/li>
  • STEP 2: SET size=0./li>
  • STEP 3: DEFINE c./li>
  • STEP 4: PRINT new line./li>
  • STEP 5: SET size=5/li>
  • STEP 6: DEFINE i, j, k./li>
  • STEP 7: SET i = 0. REPEAT STEP 8 to STEP 14 UNTIL i< (size+1) /li>
  • STEP 8: SET j=size. REPEAT STEP 9 UNTIL j>i./li>
  • STEP 9: PRINT "" and SET j=j-1/li>
  • STEP 10: SET k=0. REPEAT STEP 11 and 12 UNTIL k<(2*i-1)/li>
  • STEP 11: PRINT * /li>
  • STEP 12: SET k=k+1/li>
  • STEP 13: PRINT new line./li>
  • STEP 14: SET i= i+1./li>
  • STEP 15: END

All Answers

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

Program:

class pattern  
  
   public static void main(String[] args)  
 {  
   int size = 0;  
       Character c;  
       System.out.println();  
       size = 5;  
       int i, j, k;  
       for (i = 0; i < size + 1; i++) { for (j = size; j > i; j--) {  
               System.out.print(" ");  
           }  
           for (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...