Make a Logic

First, solve the problem. Then, write the code.. ~John Johnson

C - Language

If debugging is the process of removing software bugs, then programming must be the process of putting them in.. ~Edsger Dijkstra

C++

Programs must be written for people to read, and only incidentally for machines to execute.. ~Abelson / Sussman

JAVA

Everybody in this country should learn to program a computer, because it teaches you how to think.. ~Steve Jobs

Just doit..

A language that doesn't affect the way you think about programming is not worth knowing.. ~Alan J. Perlis

Sunday, June 12, 2016

Write a Java Program To Print following Pattern:

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


Sol:  public class PtrNum2  {

          public static void main( String arg[]) {    

         for(int i=1;i<=5;i++) {

             for(int j=5;j>=i;j--) { 

               System.out.print(j+" "); 

           } 

          System.out.println(); 

       }

    }

}

Output:  
Share:

Write a Java Program To Print following Pattern:

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

Sol:  class PtrNum1 {
         public static void main( String arg[]) {
         for(int i=1;i<=5;i++) {
            for(int j=1;j<=i;j++) {
                System.out.print(j+" ");
            }
           System.out.println();
        }
    }
}

Output:

Share:

Recent Posts

Unordered List

Contact Us

Theme Support