-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ6.java
More file actions
27 lines (23 loc) · 732 Bytes
/
Copy pathJ6.java
File metadata and controls
27 lines (23 loc) · 732 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
27
/*
> Date Created: 20-04-2026
> Author: Ishaan Rastogi
> Purpose: To print numbers from 1 to n and n to 1 respectively
> Operating System: This is only for Windows OS, it may or may not work on other OS
> Program Status: 100% Working
*/
import java.util.*;
class J6 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of numbers:");
int n = sc.nextInt();
System.out.println("Numbers from 1 to n:");
for (int i = 1; i <= n; i++) {
System.out.println(i);
}
System.out.println("Numbers from n to 1:");
for (int j = n; j >= 1; j--) {
System.out.println(j);
}
}
}