Tuesday, January 24, 2017

Alphabet Pattern Java :)

Tags

This Program prints the following Pattern:
A
BB
CCC
DDDD
EEEEE


package patterns;

import java.util.*;

public class pattern1 {
 
    public static void main(String args[]){
        int i,j;
        char c='A';
        Scanner in=new Scanner(System.in);
        System.out.println("Enter the Length of Pattern: ");
        int n=in.nextInt();
        System.out.println("\nPattern is:");
        for(i=1;i<=n;i++){

            for(j=1;j<=i;j++){
                System.out.print(c);
            }
            c++;
            System.out.println();
        }
    }
}