Table of Contents
Java program to print reverse pyramid.
This program will help us to understand the working of nested for loop. It will help students with their studiesimport java.util.Scanner; //Author -> ITVoyagers, visit -> itvoyagers.in class Pattern { public static void main(String[] args) { int i, j, k; for(i = 5; i >= 1; i--) { for(k=i-1; k<=5; k++) { System.out.print(" "); } //Author -> ITVoyagers, visit -> itvoyagers.in for(j = i; j >=1; j--) { System.out.print("* "); } System.out.print("n"); } //Author -> ITVoyagers, visit -> itvoyagers.in } }
Output :
* * * * * * * * * * * * * * *