-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ7.java
More file actions
26 lines (24 loc) · 749 Bytes
/
Copy pathJ7.java
File metadata and controls
26 lines (24 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
> Date Created: 23/04/2026
> Author: Ishaan Rastogi
> Purpose: To print an inverted pyramid
> Operating System: This is only for Windows OS, it may or may not work on other OS
> Program Status: 100% Working
*/
import java.util.Scanner;
class J7 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows in the pyramid: ");
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i - 1; j++) {
System.out.print(" ");
}
for (int k = 1; k <= 2 * (n - i) + 1; k++) {
System.out.print("* ");
}
System.out.println();
}
}
}