-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.java
More file actions
46 lines (36 loc) · 1.05 KB
/
Loops.java
File metadata and controls
46 lines (36 loc) · 1.05 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
import java.util.*;
public class Loops {
public static void main (String [] args){
// //for loop
// for(int counter=0; counter<10 ; counter++){
// System.out.println("Hello World");
// }
// for(int i=0; i<11; i++){
// System.out.print(i+ " ");
// }
// // while loop
// int i=0;
// while(i<11){
// System.out.print(i+" ");
// i++;
// }
// // Do While Loop
// int k=0;
// do{
// System.out.println(k);
// k++;
// }while(k<11);
// Print Sum of n natural numbers
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
// int sum = 0;
// for(int i=1; i<=n; i++){
// sum= sum+i;
// }
// System.out.println(sum);
// Print the table of a number input by the user
for(int i = 1; i<11; i++){
System.out.println(i*n);
}
}
}