Wednesday, 7 September 2016

Java program to print below pattern

Java program to print following pattern

 6 5 4 3 2 1 
 6 5 4 3 2 
 6 5 4 3 
 6 5 4 
 6 5 
 6 

Answer :

public class Pattern3 {

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

No comments:

Post a Comment