Sunday, March 29, 2020

Reverse Pyramid star patterns in java

To print  reverse pyramid pattern  in java is same like we do print pyramid in increment size. the only think change here is , here we run i ( row) loop in reverse manner.
public class Pattern1 {

 public static void main(String[] args) {
  
  for(int i=4;i>=0;i--)
  {
   for(int j=0;j<=i;j++)
   {
    System.out.print("*");
   }
   System.out.println();
  }
 }
}
OUTPUT:-
 *****
 ****
 ***
 **
 *


No comments:

Post a Comment