Computer Science, asked by shoubhit58, 8 months ago

Write a program in java to print the following output
1 A B C D
2 A B C
3 A B
4 A

Answers

Answered by amitabhvns2002
2
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);

//Taking rows value from the user

System.out.println("How many rows you want in this pattern?");

int rows = sc.nextInt();

System.out.println("Here is your pattern....!!!");

int alphabet = 65; // ASCII value of alphabet 'A'

for (int i= rows-1; i>=0 ; i--)
{
for (int j=0; j<=i; j++)
{
System.out.print((char) (alphabet+j) + " ");
}
System.out.println();
}

//Close the resources

sc.close();
}
}

Similar questions