public class Triangle {
public static void main(String[] args) {
int i, j, t = 0;
int k;
for (i = 0; i <= 4; i++) {
for (j = t; j <= 4; j++) {
System.out.print(" ");
}
for (k = 0; k < i; k++) {
System.out.print(" * ");
t = t + 1;
}
System.out.println(" ");
}
}
}
OUTPUT:-
*
* *
* * *
* * * *
public static void main(String[] args) {
int i, j, t = 0;
int k;
for (i = 0; i <= 4; i++) {
for (j = t; j <= 4; j++) {
System.out.print(" ");
}
for (k = 0; k < i; k++) {
System.out.print(" * ");
t = t + 1;
}
System.out.println(" ");
}
}
}
OUTPUT:-
*
* *
* * *
* * * *