Half pyramid or star triangle pattern in java.
■》 code link -> click ππππ
■》Input->
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
Post a Comment