-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.java
More file actions
31 lines (28 loc) · 724 Bytes
/
Copy pathLoops.java
File metadata and controls
31 lines (28 loc) · 724 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
28
29
30
31
import java.util.*;
public class Loops {
public static void main(String[] args){
int n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number : ");
n = sc.nextInt();
int i = 0;
System.out.println("While Loop : ");
// while loop
while(i <= n){
System.out.println(+ i);
i++;
}
// do while loop
System.out.println("Do while Loop : ");
i = 0;
do{
System.out.println(+ i);
i++;
}while(i<= n);
// for loop
System.out.println("For loop : ");
for(i = 0 ; i<= n;i++){
System.out.println( + i);
}
}
}