Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

10 Feb 2024

JAVA PROGRAM - INVERTED PYRAMID STAR PATTERN


 ## Write a Java Program to Print an INVERTED PYRAMID STAR PATTERN


                                                        *  *  *  *  *  *  *  *  * 
                                                            *  *  *  *  *  *  * 
                                                                *  *  *  *  *
                                                                    *  *  *
                                                                        *


public class InvertedPyramidStarPattern { 

                        public static void main(String[] args) { 
                                            int rows = 5; 
                
                                            for (int i = rows; i >= 1; i--) { 
                                                                for (int j = 1; j <= rows - i; j++) { 
                                                                                System.out.print("  "); 
                                                                
                                                                
                                                                for (int k = 1; k <= 2 * i - 1; k++) { 
                                                                                System.out.print("* "); 
                                                                
                                                                System.out.println(); 
                                            
                        
}

No comments:

Post a Comment