Print the following pattern in Java:
54321
5432
543
54
5
noname18:
plz follow me
Answers
Answered by
9
Hi guys
for( i = 1 ; i<=N; i + + )
{
for( j = N ; j >i ;/j - - )
{
print j value
}
print new line ;
}
hope it helps
for( i = 1 ; i<=N; i + + )
{
for( j = N ; j >i ;/j - - )
{
print j value
}
print new line ;
}
hope it helps
Answered by
32
Answer:
public class Pattern
{
public static void display( )
{
int k = 5 ;
for ( int i = 5 ; i > = 0 ; i-- )
{
k = 5 ;
for ( int j = i ; j > 0 ; j-- )
{
System.out.print( k + " ") ;
k-- ;
}
System.out.println( ) ;
}
}
}
Nested Loop:
A loop inside body of another loop is called nested loop.
A nested loop is used when functioning of a loop is to be repeated a number of times.
For a value of outer loop's control variable, the inner loop completely repeats ; then the outer loop update its control variable's value and the inner loop repeat again for new value of outer loop's control value and so on.
Similar questions