Upper Triangular Pattern

WAP to print Upper Triangular Pattern

Program:
import java.util.*;
class Pattern
{
 public static void main(String args[])
 {
  int i,j,n;
  char k='A';
   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;j<=i;j++)
          {       
                   System.out.print("\t"+k);
                   k++;
          }
             System.out.print("\n");
         
          } 
 }
}
Output:


Comments

Popular posts from this blog

Sequential File Allocation

Indexed File Allocation method

Linked File Allocation