Inverted half pyramid pattern in java.

import java.util.*;
public class invertedhalfpyramid{
    public static void main(String[] args) {
        int n;
        Scanner sc=new Scanner(System.in);
        System.out.println("enter number of row=");
        n=sc.nextInt();
        for(int i=n; i>=1; i--){
            for(int j=1; j<=i; j++){
            System.out.print("*");
            }
            System.out.println();
        }
    }
}

enter number of row=>5

*****
****
***
**
*
-----------------------------------------------------------------


Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.