
Write a program to draw a triangle of stars given N the number of stars at the bottom line. can assume that N will always be an odd number with a minimum value of 3.
thanks...

The given code accepts the number from the user. Accordingly, the pyramid of aestricks is displayed.
import java.util.*;
public class Pattern {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.print("Enter N: ");
int N=input.nextInt();
for(int i=1;i<=N;i++) {
for(int j=0;j<N-i;j++)System.out.print(" ");
for(int j=0;j<(2*i-1);j++) System.out.print("*");
System.out.println();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.