top of page
Writer's pictureThe Tech Platform

Write a Program to Print Down Triangle Star Pattern in Java

Code:

import java.util.Scanner;  
public class DownTrianglePattern  
{  
public static void main(String[] args)  
{  
int i, j, k, rows=9; 
System.out.print("DOWN TRIANGLE STAR PATTERN");
for (i=rows; i>= 1 ; i--)  
{  
for (j = i; j<rows ; j++)   
{  
System.out.print(" ");  
}     
for (k = 1; k <= (2*i -1) ;k++)   
{  
if( k==1 || i == rows || k==(2*i-1))   
{  
System.out.print("*");  
}  
else   
{  
System.out.print(" ");  
}  
}  
System.out.println("");  
}  
}  
}


Output:




Source: javapoint


The Tech Platform

0 comments

Comments


bottom of page