File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
InterviewPrograms/src/com/java/patterns Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .java .patterns ;
2+
3+ import java .util .Scanner ;
4+
5+ /*
6+ * Write a Java Program to print the following Pattern
7+
8+ 1
9+ 1 2
10+ 1 2 3
11+ 1 2 3 4
12+ 1 2 3 4 5
13+ 1 2 3 4 5 6
14+ */
15+ public class Pattern1 {
16+ public static void main (String [] args ) {
17+ Scanner scanner = new Scanner (System .in );
18+ System .out .println ("Enter the number of rows to print the pattern :: " );
19+ int N = Integer .parseInt (scanner .nextLine ().trim ());
20+ for (int i =1 ;i <=N ;i ++){
21+ for (int j =1 ;j <=i ;j ++)
22+ System .out .print (j +" " );
23+ System .out .println ();
24+ }
25+ scanner .close ();
26+ }
27+ }
28+ /*
29+ OUTPUT
30+ Enter the number of rows to print the pattern :: 10
31+ 1
32+ 1 2
33+ 1 2 3
34+ 1 2 3 4
35+ 1 2 3 4 5
36+ 1 2 3 4 5 6
37+ 1 2 3 4 5 6 7
38+ 1 2 3 4 5 6 7 8
39+ 1 2 3 4 5 6 7 8 9
40+ 1 2 3 4 5 6 7 8 9 10
41+ */
You can’t perform that action at this time.
0 commit comments