Computer Science, asked by Mohitkumar7516, 7 months ago

Write the program in java to display the following patterns

Attachments:

Answers

Answered by belamkarshraddha
0
class pro
{
public static void main()
{
System.out.println(“1”);

System.out.println(“2 1”);

System.out.println(“3 2 1”);

System.out.println(“4 3 2 1”);

System.out.println(“5 4 3 2 1”);
}
}







Answered by satyamlal
0

Answer:

public class Main{

public static void main(String[] args){

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

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

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

           }

           System.out.println();

       }

   }

}

Explanation:

Run two different loops for Row and column and print the value of j.

First loop will run in increasing order till 5(or till whatever row you want, it can 7 or 8 or 10 or anything) and 2nd will run in decreasing order till 1.

Similar questions