Aim:- Write a program to print following pattern
1
1 2
1 2 3
1 2 3.........................N
Software used:- Notepad, Command prompt
Program coding:-
public class trangle {
public static void main(String[] args) {
int rows = 9;
for(int i = 1; i <= rows; i++) {
for(int j = 1; j <= i; j++) {
System.out.print(j + " ");
}
System.out.println();
}
}
}
Output:-
0 Comments
if you have any problem, please let me know