Inverted And Rotated Half Pyramid Pattern Output Result Image Screenshot.
Code:
public class Inverted_Rotated_Half_Pyramid {
public static void irhp(int n) {
// outer
for (int i = 1; i <= n; i++) {
// spaces
for (int j = 1; j <= n; j++) {
System.out.print(" ");
}
// stars
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
public static void main(String[] args) {
irhp(7);
}
}
sgd
No comments:
Post a Comment