Sunday, January 22, 2017

Right Angle Number Triangle

Tags

Following program accepts no of rows and print a triangle pattern as given below:

Test Data
Input number of rows :5
 Output :
1
12
123
1234
12345

import java.util.*;
public class Inches 
{
    
    public static void main(String[] nt)
    {
      
        Scanner in=new Scanner(System.in);
        System.out.println("Enter Number of rows");
        int x=in.nextInt();

        System.out.println("Pattern is");
        for(int i=1;i<=x;i++)
    {   for(int j=1;j<=i;j++)
        {  
            System.out.print(j);
        }
        System.out.println();
    }
    }
    
}
Output: