-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop_practise_1.java
40 lines (35 loc) · 1.17 KB
/
loop_practise_1.java
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
28
29
30
31
32
33
34
35
36
37
38
39
40
public class loop_practise_1 {
public static void main(String[] args) {
// here we are gonna make a program that prints all even and odd between 1&100
// both in increasing and decreasing order
// increasing even
System.out.println("Even numbers in increasing order: ");
for(int i = 1; i <=50; i++){
if(i%2 == 0){
System.out.print(i + " ");
}
}
System.out.println(" ");
System.out.println("Even numbers in decreasing order: ");
for(int i = 50; i >= 1; i--){
if(i%2 == 0){
System.out.print(i + " ");
}
}
System.out.println(" ");
System.out.println("Odd numbers in increasing order: ");
for(int i = 1; i <=50; i++){
if(i%2 != 0){
System.out.print(i + " ");
}
}
System.out.println(" ");
System.out.println("Odd numbers in decreasing order: ");
for(int i = 50; i >= 1; i--){
if(i%2 != 0){
System.out.print(i + " ");
}
}
System.out.println(" ");
}
}