public class Main
{
public static void main(String[] args) {for (int i=0; i<6; i++)
{
for (int j=0; j<i; j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}
I have this code but it is printing half triangle like shown below
*
**
***
****
*****
I want to print a full triangle.....
Triangle programe in java
public class main {
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5 - i; j++) {
System.out.print(" ")
} for (int k = 0; k <= i; k++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
Output
*
* *
* * *
* * * *
* * * * *