Computer Science, asked by nomanmr41, 10 hours ago

write the java program for th following pattern. 1 2 3 4 5 6 7. 1 2 3 4 5 6. 1 2 3 4 5. 1 2 3 4. 1 2 3. 1 2. 1. 1 2. 1 2 3. 1 2 3 4. 1 2 3 4 5. 1 2 3 4 5 6. 1 2 3 4 5 6 7.​

Answers

Answered by devarchanc
0

Question

Write the java program for the following pattern :

1 2 3 4 5 6 7

1 2 3 4 5 6

1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4 5 6

1 2 3 4 5 6 7

Explanation:

public class Pattern

{

      public static void main(String[] args)

   {

       int a = 1;

       for (int i = 7; i > 0; i--) {

           for (int j = 1; j <= i; j++)  

               System.out.print(a++ + "\t");

           a=1;

           System.out.println();

       }

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

           for (int j = i; j > 0 ; j--)  

               System.out.print(a++ + "\t");

           a=1;

           System.out.println();

           }

   }

}

Similar questions