Half pyramid or star triangle pattern in java.

■》 code link -> click πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡



■》Input->


import java.util.*;
public class halfpyramid {
    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=1; i<=n; i++){
            for(int j=1; j<=i; j++){
            System.out.print("*");
            }
            System.out.println();
        }
    }
}

■》 Output->

enter number of row=>6

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


Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.