pattern for loop

int val= 10;
for (int row = 1; row<=4; row ++ )
{
for(int col = 1; col<=row; col++)
{
System.out.print(val+” “);
val–;
}
System.out.println();

}

out put
10
9 8
7 6 5
4 3 2 1


This content originally appeared on DEV Community and was authored by hema latha

int val= 10;
        for (int row = 1; row<=4; row ++ )
   {
       for(int col = 1; col<=row; col++)
       {
           System.out.print(val+" ");
           val--;
       }
       System.out.println();

}

out put 
10 
9 8 
7 6 5 
4 3 2 1 


This content originally appeared on DEV Community and was authored by hema latha


Print Share Comment Cite Upload Translate Updates
APA

hema latha | Sciencx (2025-03-02T18:07:59+00:00) pattern for loop. Retrieved from https://www.scien.cx/2025/03/02/pattern-for-loop/

MLA
" » pattern for loop." hema latha | Sciencx - Sunday March 2, 2025, https://www.scien.cx/2025/03/02/pattern-for-loop/
HARVARD
hema latha | Sciencx Sunday March 2, 2025 » pattern for loop., viewed ,<https://www.scien.cx/2025/03/02/pattern-for-loop/>
VANCOUVER
hema latha | Sciencx - » pattern for loop. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/03/02/pattern-for-loop/
CHICAGO
" » pattern for loop." hema latha | Sciencx - Accessed . https://www.scien.cx/2025/03/02/pattern-for-loop/
IEEE
" » pattern for loop." hema latha | Sciencx [Online]. Available: https://www.scien.cx/2025/03/02/pattern-for-loop/. [Accessed: ]
rf:citation
» pattern for loop | hema latha | Sciencx | https://www.scien.cx/2025/03/02/pattern-for-loop/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.