Java Program:

- To print half reverse triangle pattern using *

Example:

User Input: 4

Output:

* * * *
* * *
* *
*
import java.util.Scanner;

public class Pattern {

  public static void main(String[] args) {
    Scanner userInput = new Scanner(System.in);
    System.out.print("Enter number of rows : ");

    int rows;
    rows=userInput.nextInt();
    for(int i=rows; i>=1; i--) {
      for(int j=1; j<=i; j++) {
        System.out.print("* ");
      }
      System.out.print("\n");
    }

  }
}

Output:

  Enter number of rows : 4
  * * * *
  * * *
  * *
  *
Program
pattern

Main logic :

for(int i=rows; i>=1; i--) {  //rows : number of rows to print
  for(int j=1; j<=i; j++) {
    cout<<"* ";
  }
  cout<<endl;
}

You can print any thing in this pattern, just replace your value with *

Concept

Coming Soon !

Quick
Tutorial

Quote

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.