Pattern Program in JAVA

Pattern Program - 1



Program to display the following number pattern on screen.

Pattern :-

1
12
123
1234
12345



Program below :-

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      
               

Comments

Popular posts from this blog

Frequency of each digit of a number in Java

Trimorphic Number in JAVA

PalPrime Number in JAVA