Explanation :
If n=6 then output will be
1
23
345
4567
56789
67891011.
Code:
import java.util.Scanner;public class Pattern13
{
public static void main( String arg[])
{
System.out.print("Enter the number of rows:");
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i,j,k;
for (i=1;i<=n;i++)
{
j=i;
for (k=1;k<=i;k++)
{
System.out.printf("%d",j++);
}
System.out.printf("\n");
}
sc.close();
}
}
No comments:
Post a Comment