Java program to print the pascal triangle using star

Java program to print the pascal triangle using star. In the Java programming language,the right pascal triangle pattern is used. The asterisk right side pascal triangle will be printed by this application. In the java programming language,the asterisk is used to print this right angle pascal program. Beginners in the field of software development may use the triangle pascal program in Java.

import java.util.Scanner; 
public class Main
{ 
public static void main(String[] args) 
{ 
int i, j, rows; 
Scanner sc = new Scanner(System.in); 
System.out.print("Enter the numbers"); 
rows = sc.nextInt(); 
for (i= 0; i<= rows-1; i++) 
{ 
for (j=0; j<=i; j++) 
{ 
System.out.print("*"+ " "); 
} 
System.out.println(""); 
} 
for (i=rows-1; i>=0; i--) 
{ 
for(j=0; j <= i-1;j++) 
{ 
System.out.print("*"+ " "); 
} 
System.out.println(""); 
} 
} 
} 

 

Output:

enter the numbers5

*

* *

* * *

* * * *

* * * * *

* * * *

* * *

* *

*