Menu BAR

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

10 Feb 2024

JAVA PROGRAM - PYRAMID STAR PATTERN


## Write a Java program to print the PYRAMID STAR PATTERN? 



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


public class PyramidStarPattern { 

                        public static void main(String[] args) { 
                                        int rows = 5; 

                                        for (int i = 1; i <= rows; 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