Upper triangle number pattern

WAP to print upper triangle number pattern
Program:
import java.util.*;
class Pattern
{
 public static void main(String args[])
 {
  int i,j,k=1,n;
   Scanner sc=new Scanner(System.in);
   System.out.println("Enter the number of rows");
   n=sc.nextInt();
   System.out.print("\n");
    for(i=0;i<n;i++)
          {  
          for(j=0;i>=j;j++)
          {
                   System.out.print(k);
                   k++;
          }
             System.out.print("\n");
         
          } 
 }

}

Output:




Comments

Popular posts from this blog

Sequential File Allocation

Indexed File Allocation method

Linked File Allocation