DEV Community

hema latha
hema latha

Posted on

pattern for loop program

public static void main(String[] args) {
        // TODO Auto-generated method stub
        int val=5;
   for(int row = 1; row<=5; row ++ )
   {
       for(int col = 1; col<=row; col++)
       {
           System.out.print(val+" ");
       }
       System.out.println();    
       val--;
   }
out put - 
5 
4 4 
3 3 3 
2 2 2 2 
1 1 1 1 1 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay