Thursday 20 July 2017

number pattern program

import java.util.Scanner;

public class Number{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
       
        System.out.println("How many rows you want in this pattern?");
       
        int rows = sc.nextInt();
       
        System.out.println(" number pattern");
       
        for (int i = 1; i <= rows; i++)
        {
            for (int j = 1; j <= rows-i; j++)
            {
                System.out.print(1);
            }
           
            for (int j = 1; j <= i; j++)
            {
                System.out.print(i);
            }
           
            System.out.println();
        }
       
        sc.close();
    }
}





OUTPUT:

How many rows you want in this pattern?
9
 number pattern
111111111
111111122
111111333
111114444
111155555
111666666
117777777
188888888

999999999

No comments:

Post a Comment