Pattern Program #1
Program to display the following number pattern on screen.
Pattern :-
1 12 123 1234 12345
Program :-
class Pattern { public static void main(String args[]) { int i,j; for(i=1;i<=5;i++) // Loop for No. of rows { for(j=1;j<=i;j++) //Loop for No. of columns { System.out.print(j); // Print the number in the same line till it is equal to i } System.out.println(); // Now the element will be printed in the next line when loop is executed } } // end of main method } // end of class
Note : The program is written in the easiest way possible so try understand it. If you face any problem in understanding this program than feel free to contact/comment.
All the Best :)
Keep Learning :)
ความคิดเห็น