Question
Write a java program to display following pattern:
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
Solution
Hey, folks, today I will help you in solving core java slips of T.Y.B.C.A. InT.Y.B.C.A.In this program, you’ll learn to Write a java program to display following pattern:
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
Code
import java.io.*;
public static void drawPyramidPattern() {
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