-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEach_loop2.java
More file actions
23 lines (20 loc) · 806 Bytes
/
Copy pathEach_loop2.java
File metadata and controls
23 lines (20 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package loop;
import java.util.Scanner;
public class Each_loop2 {
public static void main(String[] args) {
int rows, number = 1, counter, j;
Scanner input = new Scanner(System.in); // to get user is input
System.out.println("Enter the number of rows for floyed's triangle :"); // Copying user into an integer variable named rows
rows = input.nextInt();
System.out.println("Floyd's triangle");
System.out.println("****************");
for( counter= 1; counter <= rows; counter++){
for(j = 1; j <= counter; j++){
System.out.print(number+" "); // Increamenting the number value
number ++;
}
// for new line
System.out.println();
}
}
}