Explain me the execution of this loop in Java:1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Answers
Answered by
2
public class Example
{
public static void main(String[] args)
{
int a = 5;
for(int i=a; i>=1;--i)
{
for(int j=1; j<=i;++j)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
{
public static void main(String[] args)
{
int a = 5;
for(int i=a; i>=1;--i)
{
for(int j=1; j<=i;++j)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Answered by
0
Heya user
Here is your answer !!
_____________
public class Series
{
public static void main ( String args [] )
{
int n , a ;
for ( n = 5 ; n >= 1 ; n-- )
{
for ( a = 1 ; a <= n ; a++ )
System.out.println ( a ) ;
}
}
______________
Hope it helps !!
Here is your answer !!
_____________
public class Series
{
public static void main ( String args [] )
{
int n , a ;
for ( n = 5 ; n >= 1 ; n-- )
{
for ( a = 1 ; a <= n ; a++ )
System.out.println ( a ) ;
}
}
______________
Hope it helps !!
Similar questions
Social Sciences,
8 months ago
Math,
1 year ago