Science, asked by AkankshaTinni, 1 year ago

Write a program in JAVA to print the following pattern:
1
2 4
1 3 5
2 4 6 8
1 3 5 7 9

Answers

Answered by veer2627
0

Answer:

increasing to decresing

123456789

decreasing to increasing

987654321

hpe this helps you please follow me and thanks me

Answered by bhuniaarman
1

Answer:

Hope this helps you .

class Coding_Program  

{

   public static void main(int n)  

   {

     int i, j, k;

     for (i = 1; i <= n; i++)  

     {

       if (i % 2 == 0)  

       {

          k = 2;

       }

       else  

       {

          k = 1;

       }

        for (j = 1; j <= i; j++, k += 2)  

        {

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

        }

        System.out.println();

     }

   }

}

Explanation:

Please mark my answer as the brainlest answer.

Similar questions