Skip to content

Commit 2f440e2

Browse files
committed
pattern 2
1 parent 38fe3a1 commit 2f440e2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ucer/4B4/Pattern2.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Program to print the following pattern
2+
1
3+
2 3
4+
4 5 6
5+
7 8 9 10
6+
*/
7+
8+
import java.util.Scanner;
9+
public class Pattern2{
10+
public static void main(String args[])
11+
{
12+
System.out.print("How many line you want to display: ");
13+
Scanner reader = new Scanner(System.in);
14+
int nl = reader.nextInt();
15+
int temp = 0;
16+
for(int i= 0; i < nl; i++)
17+
{
18+
for(int j= 0; j <= i; j++)
19+
{
20+
temp++;
21+
System.out.print(temp + "\t");
22+
}
23+
System.out.print("\n");
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)