Skip to content

Commit 16f5344

Browse files
committed
Pattern 11
1 parent 376af1a commit 16f5344

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.java.patterns;
2+
3+
import java.util.Scanner;
4+
5+
/*
6+
Write a Java Program to print the following Pattern
7+
1 1 1 1 1
8+
2 2 2 2 2
9+
3 3 3 3 3
10+
4 4 4 4 4
11+
5 5 5 5 5
12+
*/
13+
public class Pattern11 {
14+
public static void main(String[] args) {
15+
Scanner scanner = new Scanner(System.in);
16+
System.out.println("Enter the number of rows to print the pattern :: ");
17+
int N = Integer.parseInt(scanner.nextLine().trim());
18+
for(int i=0;i<N;i++){
19+
for(int j=0;j<5;j++)
20+
if(j == 4)
21+
System.out.print((i+1)+"");
22+
else
23+
System.out.print(i+1+" ");
24+
if(i < N-1)
25+
System.out.println("");
26+
}
27+
scanner.close();
28+
}
29+
}
30+
/*
31+
OUTPUT
32+
Enter the number of rows to print the pattern :: 5
33+
1 1 1 1 1
34+
2 2 2 2 2
35+
3 3 3 3 3
36+
4 4 4 4 4
37+
5 5 5 5 5
38+
39+
Enter the number of rows to print the pattern :: 2
40+
1 1 1 1 1
41+
2 2 2 2 2
42+
*/

0 commit comments

Comments
 (0)