Monday, January 19, 2015

2. Star Pattern Program in Java

Star Pattern Program in Java

The following star pattern will be printed.


The program is shown below :

1: import java.util.Scanner;  
2:    
3:  class StarPattern2  
4:  {  
5:       public static void main(String[] args)  
6:       {  
7:            int n;  
8:            System.out.println("Enter the number till you want a star pattern");  
9:            Scanner scan = new Scanner(System.in);  
10:            n = scan.nextInt();  
11:    
12:            label:     for(int i=0; i0; k--)  
15:                      {  
16:                           System.out.print(" ");  
17:                      }  
18:                      for(int j=0; j

Output :


No comments:

Post a Comment