-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.java
More file actions
52 lines (46 loc) · 1.18 KB
/
loops.java
File metadata and controls
52 lines (46 loc) · 1.18 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
package com.company;
import java.util.Scanner;
public class loops {
public static void main(String[] args) {
//While loop
/*int i = 0;
while (i < 1000){
i++;
System.out.println(i);
}*/
//Quiz 1
/*int b =100;
while (b!=201) {
System.out.println(b);
b++;
}*/
//Do while
/* int l = 5;
do{
l++;
System.out.println(l);
}while (l!=5);*/
//for loop
/*for (int i = 1; i != 11; i++){
System.out.println(i);
}*/
//Quiz 2
/* Scanner sc = new Scanner(System.in);
System.out.print("Tell number : ");
int rows = sc.nextInt();
for (int i = 1; i!=rows+1; i++){
if (i%2==0){
System.out.println(i + " is even");
}else{
System.out.println(i + " is odd");
}
}*/
//Quiz 3
Scanner sc = new Scanner(System.in);
System.out.print("Tell number : ");
int number = sc.nextInt();
for (int i = number; i!=0; i--){
System.out.println(i);
}
}
}