A java program on
1
23
456
78910
1112131415
Answers
Answer:
import java.util.Scanner;
public class pattern
{
public static void FloydTriangle( )
{
int c, d, num = 1 ;
for( c = 1 ; c < = 5 ; c++ )
{
for( d = 1 ; d < = c ; d++ )
{
System.out.print(num + " " )
num++ ;
}
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.
Explanation:
HELLO MATE!!! HOPE YOU ARE HAVING A NICE DAY ... WITHOUT WASTING ANYTIME HERE IS YOUR PROGRAM
public class
{
public static void main(String[]args)
{
int i = 0 , j = 0 ;
int num = 1 ;
for(i = 0 ; i <= 5 ; i++)
{
for(j = 1 ; j <= i ; j++)
{
num++;
System.out.print(" "+num);
}
}
}
}