Monday, January 19, 2015

Star Pattern Program in Java


 Star Pattern Program in Java

The following star pattern will be printed.



The program is shown below :
import java.util.Scanner;  
    
  class StarPattern1  
  {  
       public static void main(String[] args)  
       {  
            int n;  
            System.out.println("Enter the number till you want a star pattern");  
            Scanner scan = new Scanner(System.in);  
            n = scan.nextInt();  
    
            label:     for(int i=0; ii)  
                           {  
                                System.out.println();  
                                continue label;  
                           }  
                           else  
                           {  
                                System.out.print("*");  
                           }  
                      }  
                 }  
       }  
  } 

Output :






No comments:

Post a Comment