Reverse Star Triangle Using Java
Previous | Home | Next |
Reverse Star Triangle Using Java
//Following program for Print Star in trianguler shape
package r4r.co.in;
import java.io.*;
public class NewClass {
public static void main(String[] args) throws IOException {
BufferedReader Star = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the no.to be print:");
String s = Star.readLine();
int n1 = Integer.parseInt(s);
//Triangle Star print:Reversed order
try {
for (int i = 0; i <= n1; i++) { //Star print in Decending order
for (int j = i; j <= n1 - 1; j++) {
System.out.print("*");
}
System.out.println("");
}
} catch (Exception e) {
System.out.print(e);
}
}
}
Enter the no.to be print:
10
**********
*********
********
*******
******
*****
****
***
**
*
Previous | Home | Next |