- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAfForLoop.java
More file actions
Latest commit
30 lines (24 loc) · 651 Bytes
/
Copy pathAfForLoop.java
File metadata and controls
30 lines (24 loc) · 651 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
packagebas1;
importjava.util.Scanner;
publicclassAfForLoop {
publicstaticvoidmain(String[] args) {
intn = 5;
for (inti = 1; i <= n; ++i) {
System.out.println("Java is fun");
}
intfact = 1;
Scannerreader = newScanner(System.in);
System.out.println("Enter a number to do factorial");
intn1 = reader.nextInt();
// for loop
for (inti = 1; i <= n1; ++i) {
// body inside for loop
fact *= i; // sum = sum + i
}
System.out.println("fact = " + fact);
reader.close();
/*
* for (int i = 1; i <= 10; --i) { System.out.println("Hello"); }
*/
}
}